 |
|
 |
|
Next: PHP Question: Local File Functions (Move, Delete,..
|
| Author |
Message |
External

Since: Jan 31, 2005 Posts: 30
|
(Msg. 1) Posted: Sun Feb 20, 2005 5:40 am
Post subject: SQL- using lst box to gatehr info for a specidi field. Archived from groups: comp>lang>basic>visual>database (more info?)
|
|
|
hi,
i've got an access table called 'submission_info', and in that table i've
got fields with names of people, and addresses. i want to show a list of
papers from a specific country. e.g. China.
this is what i've strung together so far;
Private Sub cmdCountry_Click()
'strVar = txtCountry
'strSQL = "SELECT paper_title FROM submission_info WHERE
contact_author_address_5 = '"strVar'"
sql = "SELECT paper_title FROM submission_info WHERE
contact_author_address_5 = 'China'"
txtCountry.Text = sql
End Sub
but it aint working correctly, it just displays the whole sql line. i know
that code is wrong!! i have a list box called 'lstCountry, where the
user can pick a country name, and then the rest of teh fields get updated
with that info. only problem is, i dont know how i want to display it? e.g.
as a form with fields, or as a list box. ??
thanx
devin >> Stay informed about: SQL- using lst box to gatehr info for a specidi field. |
|
| Back to top |
|
 |  |
External

Since: Apr 22, 2004 Posts: 13
|
(Msg. 2) Posted: Sun Feb 20, 2005 11:40 am
Post subject: Re: SQL- using lst box to gatehr info for a specidi field. [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
How are you accessing your database ADO, Bound Controls, Data
Environment?....
--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
<a style='text-decoration: underline;' href="http://www.veign.com/vrc_main.asp" target="_blank">http://www.veign.com/vrc_main.asp</a>
--
"Devin Panchal" wrote in message
> hi,
>
> i've got an access table called 'submission_info', and in that table i've
> got fields with names of people, and addresses. i want to show a list of
> papers from a specific country. e.g. China.
>
> this is what i've strung together so far;
>
> Private Sub cmdCountry_Click()
>
> 'strVar = txtCountry
>
> 'strSQL = "SELECT paper_title FROM submission_info WHERE
> contact_author_address_5 = '"strVar'"
>
> sql = "SELECT paper_title FROM submission_info WHERE
> contact_author_address_5 = 'China'"
> txtCountry.Text = sql
>
> End Sub
>
> but it aint working correctly, it just displays the whole sql line. i know
> that code is wrong!! i have a list box called 'lstCountry, where the
> user can pick a country name, and then the rest of teh fields get updated
> with that info. only problem is, i dont know how i want to display it?
e.g.
> as a form with fields, or as a list box. ??
>
> thanx
> devin
>
>
>
><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: SQL- using lst box to gatehr info for a specidi field. |
|
| Back to top |
|
 |  |
External

Since: Oct 06, 2003 Posts: 50
|
(Msg. 3) Posted: Sun Feb 20, 2005 11:42 am
Post subject: Re: SQL- using lst box to gatehr info for a specidi field. [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Devin Panchal wrote:
> hi,
>
> i've got an access table called 'submission_info', and in that table i've
> got fields with names of people, and addresses. i want to show a list of
> papers from a specific country. e.g. China.
>
> this is what i've strung together so far;
>
> Private Sub cmdCountry_Click()
>
> 'strVar = txtCountry
>
> 'strSQL = "SELECT paper_title FROM submission_info WHERE
> contact_author_address_5 = '"strVar'"
>
> sql = "SELECT paper_title FROM submission_info WHERE
> contact_author_address_5 = 'China'"
> txtCountry.Text = sql
>
> End Sub
>
> but it aint working correctly, it just displays the whole sql line. i know
Sure it is! The computer's doing exactly what
you're telling it to! (Sorry, I couldn't just
leave a straight line like that hanging!
> that code is wrong!! i have a list box called 'lstCountry, where the
> user can pick a country name, and then the rest of teh fields get updated
> with that info. only problem is, i dont know how i want to display it? e.g.
> as a form with fields, or as a list box. ??
I don't know the effect you're looking for, but
the fact that you want a varying amount of info
on the screen suggests you may want a
Hierarchical Flexgrid. That way you can set it
up with scroll bars in case you have like 100
papers from China. You can have separate
columns for author, title, and any other info
you want to display.
You can also set different text and background
colors in each cell.
There are a lot of fiddly little properties to
set to get it looking just right, but it's a
control you'll find a lot of uses for...
>
> thanx
> devin<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: SQL- using lst box to gatehr info for a specidi field. |
|
| Back to top |
|
 |  |
External

Since: Jan 31, 2005 Posts: 30
|
(Msg. 4) Posted: Mon Feb 21, 2005 2:40 pm
Post subject: Re: SQL- using lst box to gatehr info for a specidi field. [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
hi,
i know how i want it to look now.
i've gto a cbo box, called cboCountry, and that will have all the countries
in the database. then when a country is clicked (e.g. China) the
'txtCountry' field will be filled in, with info from that specific country.
it will get this info from the database. (.e.g. contact_author_first_name ,
contact_author_last_name , contact_author_address_1 , etc...)
this is the code i've got so far.
Private Sub cmdCountry_Click()
rs.Open "SELECT paper_title FROM submission_info WHERE
contact_author_address_5 ='" & cboCountry.Text & "'", Assignment2,
adOpenStatic, adLockOptimistic, adCmdText
cboCountry.AddItem rs.Fields.Item("contact_author_address_5")
End Sub
how do i get it to fill in the txtCountry field?? i've also got a button to
trigger all of this. do i really need it? the button is cmdCountry.
thanx
devin
"Randy Day" wrote in message
> Devin Panchal wrote:
>
> > hi,
> >
> > i've got an access table called 'submission_info', and in that table
i've
> > got fields with names of people, and addresses. i want to show a list of
> > papers from a specific country. e.g. China.
> >
> > this is what i've strung together so far;
> >
> > Private Sub cmdCountry_Click()
> >
> > 'strVar = txtCountry
> >
> > 'strSQL = "SELECT paper_title FROM submission_info WHERE
> > contact_author_address_5 = '"strVar'"
> >
> > sql = "SELECT paper_title FROM submission_info WHERE
> > contact_author_address_5 = 'China'"
> > txtCountry.Text = sql
> >
> > End Sub
> >
> > but it aint working correctly, it just displays the whole sql line. i
know
>
> Sure it is! The computer's doing exactly what
> you're telling it to! (Sorry, I couldn't just
> leave a straight line like that hanging!
>
> > that code is wrong!! i have a list box called 'lstCountry, where the
> > user can pick a country name, and then the rest of teh fields get
updated
> > with that info. only problem is, i dont know how i want to display it?
e.g.
> > as a form with fields, or as a list box. ??
>
> I don't know the effect you're looking for, but
> the fact that you want a varying amount of info
> on the screen suggests you may want a
> Hierarchical Flexgrid. That way you can set it
> up with scroll bars in case you have like 100
> papers from China. You can have separate
> columns for author, title, and any other info
> you want to display.
>
> You can also set different text and background
> colors in each cell.
>
> There are a lot of fiddly little properties to
> set to get it looking just right, but it's a
> control you'll find a lot of uses for...
>
> >
> > thanx
> > devin<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: SQL- using lst box to gatehr info for a specidi field. |
|
| Back to top |
|
 |  |
External

Since: Oct 06, 2003 Posts: 50
|
(Msg. 5) Posted: Tue Feb 22, 2005 12:00 am
Post subject: Re: SQL- using lst box to gatehr info for a specidi field. [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Devin Panchal wrote:
> hi,
>
> i know how i want it to look now.
> i've gto a cbo box, called cboCountry, and that will have all the countries
> in the database. then when a country is clicked (e.g. China) the
> 'txtCountry' field will be filled in, with info from that specific country.
> it will get this info from the database. (.e.g. contact_author_first_name ,
> contact_author_last_name , contact_author_address_1 , etc...)
>
> this is the code i've got so far.
>
> Private Sub cmdCountry_Click()
>
> rs.Open "SELECT paper_title FROM submission_info WHERE
> contact_author_address_5 ='" & cboCountry.Text & "'", Assignment2,
> adOpenStatic, adLockOptimistic, adCmdText
>
> cboCountry.AddItem rs.Fields.Item("contact_author_address_5")
>
> End Sub
>
You call up the paper titles from china, then
add china to the country combobox again?
> how do i get it to fill in the txtCountry field?? i've also got a button to
> trigger all of this. do i really need it? the button is cmdCountry.
Probably not. You could get the combobox to start
the process in its Click(), DblClick() or Change()
events, That way, selecting an item in the
combobox list starts the process right off.
Read up on the combobox ListIndex() and List()
properties.<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: SQL- using lst box to gatehr info for a specidi field. |
|
| Back to top |
|
 |  |
External

Since: Jan 31, 2005 Posts: 30
|
(Msg. 6) Posted: Tue Feb 22, 2005 10:40 am
Post subject: Re: SQL- using lst box to gatehr info for a specidi field. [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
hey,
i got it to work. but i got a little problem. i got duplicated countries in
the combo box. how do i get rid of the duplicated ones?? also how do i get
'all' of the paper titles in that text field. at the moment it only shows a
paper title for that specific country, and it only shows 1 title, some
countries have more then 1. (.e.g. china has 4 different papers), but it
only shows one of them.
thanx
devin
"Randy Day" wrote in message
> Devin Panchal wrote:
> > hi,
> >
> > i know how i want it to look now.
> > i've gto a cbo box, called cboCountry, and that will have all the
countries
> > in the database. then when a country is clicked (e.g. China) the
> > 'txtCountry' field will be filled in, with info from that specific
country.
> > it will get this info from the database. (.e.g.
contact_author_first_name ,
> > contact_author_last_name , contact_author_address_1 , etc...)
> >
> > this is the code i've got so far.
> >
> > Private Sub cmdCountry_Click()
> >
> > rs.Open "SELECT paper_title FROM submission_info WHERE
> > contact_author_address_5 ='" & cboCountry.Text & "'", Assignment2,
> > adOpenStatic, adLockOptimistic, adCmdText
> >
> > cboCountry.AddItem rs.Fields.Item("contact_author_address_5")
> >
> > End Sub
> >
>
> You call up the paper titles from china, then
> add china to the country combobox again?
>
> > how do i get it to fill in the txtCountry field?? i've also got a button
to
> > trigger all of this. do i really need it? the button is cmdCountry.
>
> Probably not. You could get the combobox to start
> the process in its Click(), DblClick() or Change()
> events, That way, selecting an item in the
> combobox list starts the process right off.
>
> Read up on the combobox ListIndex() and List()
> properties.<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: SQL- using lst box to gatehr info for a specidi field. |
|
| Back to top |
|
 |  |
External

Since: Oct 06, 2003 Posts: 50
|
(Msg. 7) Posted: Tue Feb 22, 2005 10:44 am
Post subject: Re: SQL- using lst box to gatehr info for a specidi field. [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Devin Panchal wrote:
> hey,
>
> i got it to work. but i got a little problem. i got duplicated countries in
> the combo box. how do i get rid of the duplicated ones?? also how do i get
Well, as I mentioned below, you were adding
duplicates in your 'Country' button.
Beyond that, you're going to have to step
through your code to find out where
combobox.additem gets called.
If it's because your recordset returns
multiples, you'll have to explore the
'UNIQUE' keyword for your 'SELECT'
statement.
> 'all' of the paper titles in that text field. at the moment it only shows a
> paper title for that specific country, and it only shows 1 title, some
> countries have more then 1. (.e.g. china has 4 different papers), but it
> only shows one of them.
Did you add a loop to display all records
returned in your 'Country' buttion?
>
> thanx
>
> devin
>
>
>>Devin Panchal wrote:
>>
>>>hi,
>>>
>>> i know how i want it to look now.
>>>i've gto a cbo box, called cboCountry, and that will have all the
>
> countries
>
>>>in the database. then when a country is clicked (e.g. China) the
>>>'txtCountry' field will be filled in, with info from that specific
>
> country.
>
>>>it will get this info from the database. (.e.g.
>
> contact_author_first_name ,
>
>>>contact_author_last_name , contact_author_address_1 , etc...)
>>>
>>>this is the code i've got so far.
>>>
>>>Private Sub cmdCountry_Click()
>>>
>>>rs.Open "SELECT paper_title FROM submission_info WHERE
>>>contact_author_address_5 ='" & cboCountry.Text & "'", Assignment2,
>>>adOpenStatic, adLockOptimistic, adCmdText
>>>
>>>cboCountry.AddItem rs.Fields.Item("contact_author_address_5")
>>>
>>>End Sub
>>>
>>
>>You call up the paper titles from china, then
>>add china to the country combobox again?
>>
>>
>>>how do i get it to fill in the txtCountry field?? i've also got a button
>
> to
>
>>>trigger all of this. do i really need it? the button is cmdCountry.
>>
>>Probably not. You could get the combobox to start
>>the process in its Click(), DblClick() or Change()
>>events, That way, selecting an item in the
>>combobox list starts the process right off.
>>
>>Read up on the combobox ListIndex() and List()
>>properties.
>
>
><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: SQL- using lst box to gatehr info for a specidi field. |
|
| Back to top |
|
 |  |
External

Since: Feb 22, 2005 Posts: 1
|
(Msg. 8) Posted: Tue Feb 22, 2005 12:40 pm
Post subject: Re: SQL- using lst box to gatehr info for a specidi field. [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
the database i am using already has some records in it. i didnt make the
actual database. i have not got any loops. this is wat i've got;;
Private Sub cmdCountry_Click()
rs.Open "SELECT paper_title FROM submission_info WHERE
contact_author_address_5 ='" & cboCountry.Text & "'", Assignment2,
adOpenStatic, adLockOptimistic, adCmdText
txtCountry.Text = rs.Fields.Item("paper_title")
rs.Close
End Sub
and for the load ;
Private Sub Form_Load()
Set Assignment2 = New ADODB.Connection
Assignment2.Provider = "Microsoft.Jet.OLEDB.4.0;"
Assignment2.ConnectionString = "C:\...\Assignment2.mdb"
Assignment2.Open
Set rs = New ADODB.Recordset
rs.Open "select * from submission_info", Assignment2, adOpenDynmic,
adLockOptimistic
If rs.RecordCount = 0 Then
MsgBox "You have no records in the database.", vbExclamation, "Database"
'you have no records to process
Else
rs.MoveFirst
Do While Not rs.EOF
cboCountry.AddItem rs.Fields.Item("contact_author_address_5")
rs.MoveNext
Loop
rs.MoveFirst
rs.Close
End If
End Sub
the combo box gets called when the form is loaded. at the moment, it only
diplays 1 paper title, but some countries have more then 1.
thanx
devin
"Randy Day" wrote in message
> Devin Panchal wrote:
> > hey,
> >
> > i got it to work. but i got a little problem. i got duplicated countries
in
> > the combo box. how do i get rid of the duplicated ones?? also how do i
get
>
> Well, as I mentioned below, you were adding
> duplicates in your 'Country' button.
>
> Beyond that, you're going to have to step
> through your code to find out where
> combobox.additem gets called.
>
> If it's because your recordset returns
> multiples, you'll have to explore the
> 'UNIQUE' keyword for your 'SELECT'
> statement.
>
> > 'all' of the paper titles in that text field. at the moment it only
shows a
> > paper title for that specific country, and it only shows 1 title, some
> > countries have more then 1. (.e.g. china has 4 different papers), but it
> > only shows one of them.
>
> Did you add a loop to display all records
> returned in your 'Country' buttion?
>
> >
> > thanx
> >
> > devin
> >
> >
> >>Devin Panchal wrote:
> >>
> >>>hi,
> >>>
> >>> i know how i want it to look now.
> >>>i've gto a cbo box, called cboCountry, and that will have all the
> >
> > countries
> >
> >>>in the database. then when a country is clicked (e.g. China) the
> >>>'txtCountry' field will be filled in, with info from that specific
> >
> > country.
> >
> >>>it will get this info from the database. (.e.g.
> >
> > contact_author_first_name ,
> >
> >>>contact_author_last_name , contact_author_address_1 , etc...)
> >>>
> >>>this is the code i've got so far.
> >>>
> >>>Private Sub cmdCountry_Click()
> >>>
> >>>rs.Open "SELECT paper_title FROM submission_info WHERE
> >>>contact_author_address_5 ='" & cboCountry.Text & "'", Assignment2,
> >>>adOpenStatic, adLockOptimistic, adCmdText
> >>>
> >>>cboCountry.AddItem rs.Fields.Item("contact_author_address_5")
> >>>
> >>>End Sub
> >>>
> >>
> >>You call up the paper titles from china, then
> >>add china to the country combobox again?
> >>
> >>
> >>>how do i get it to fill in the txtCountry field?? i've also got a
button
> >
> > to
> >
> >>>trigger all of this. do i really need it? the button is cmdCountry.
> >>
> >>Probably not. You could get the combobox to start
> >>the process in its Click(), DblClick() or Change()
> >>events, That way, selecting an item in the
> >>combobox list starts the process right off.
> >>
> >>Read up on the combobox ListIndex() and List()
> >>properties.
> >
> >
> ><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: SQL- using lst box to gatehr info for a specidi field. |
|
| Back to top |
|
 |  |
External

Since: Oct 06, 2003 Posts: 50
|
(Msg. 9) Posted: Tue Feb 22, 2005 2:30 pm
Post subject: Re: SQL- using lst box to gatehr info for a specidi field. [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Devin wrote:
> the database i am using already has some records in it. i didnt make the
> actual database. i have not got any loops. this is wat i've got;;
>
> Private Sub cmdCountry_Click()
>
> rs.Open "SELECT paper_title FROM submission_info WHERE
> contact_author_address_5 ='" & cboCountry.Text & "'", Assignment2,
> adOpenStatic, adLockOptimistic, adCmdText
>
> txtCountry.Text = rs.Fields.Item("paper_title")
Well, here you add *1* paper title to the textbox...
> rs.Close
.... and then you wipe the recordset. The question
has to be asked: *WHY* haven't you got a loop? The
code should be similar to what you had in
form_load.
>
> End Sub
>
> and for the load ;
>
> Private Sub Form_Load()
> Set Assignment2 = New ADODB.Connection
> Assignment2.Provider = "Microsoft.Jet.OLEDB.4.0;"
> Assignment2.ConnectionString = "C:\...\Assignment2.mdb"
> Assignment2.Open
> Set rs = New ADODB.Recordset
>
> rs.Open "select * from submission_info", Assignment2, adOpenDynmic,
> adLockOptimistic
> If rs.RecordCount = 0 Then
> MsgBox "You have no records in the database.", vbExclamation, "Database"
> 'you have no records to process
> Else
> rs.MoveFirst
> Do While Not rs.EOF
> cboCountry.AddItem rs.Fields.Item("contact_author_address_5")
> rs.MoveNext
> Loop
> rs.MoveFirst
> rs.Close
>
> End If
>
> End Sub
>
> the combo box gets called when the form is loaded. at the moment, it only
> diplays 1 paper title, but some countries have more then 1.
>
> thanx
>
> devin<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: SQL- using lst box to gatehr info for a specidi field. |
|
| Back to top |
|
 |  |
External

Since: Feb 23, 2005 Posts: 1
|
(Msg. 10) Posted: Wed Feb 23, 2005 5:40 am
Post subject: Re: SQL- using lst box to gatehr info for a specidi field. [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
i got it working. thanx for the help. i was missing the loop.
dev
"Randy Day" wrote in message
> Devin wrote:
> > the database i am using already has some records in it. i didnt make the
> > actual database. i have not got any loops. this is wat i've got;;
> >
> > Private Sub cmdCountry_Click()
> >
> > rs.Open "SELECT paper_title FROM submission_info WHERE
> > contact_author_address_5 ='" & cboCountry.Text & "'", Assignment2,
> > adOpenStatic, adLockOptimistic, adCmdText
> >
> > txtCountry.Text = rs.Fields.Item("paper_title")
>
> Well, here you add *1* paper title to the textbox...
>
> > rs.Close
>
> ... and then you wipe the recordset. The question
> has to be asked: *WHY* haven't you got a loop? The
> code should be similar to what you had in
> form_load.
>
> >
> > End Sub
> >
> > and for the load ;
> >
> > Private Sub Form_Load()
> > Set Assignment2 = New ADODB.Connection
> > Assignment2.Provider = "Microsoft.Jet.OLEDB.4.0;"
> > Assignment2.ConnectionString = "C:\...\Assignment2.mdb"
> > Assignment2.Open
> > Set rs = New ADODB.Recordset
> >
> > rs.Open "select * from submission_info", Assignment2, adOpenDynmic,
> > adLockOptimistic
> > If rs.RecordCount = 0 Then
> > MsgBox "You have no records in the database.", vbExclamation, "Database"
> > 'you have no records to process
> > Else
> > rs.MoveFirst
> > Do While Not rs.EOF
> > cboCountry.AddItem rs.Fields.Item("contact_author_address_5")
> > rs.MoveNext
> > Loop
> > rs.MoveFirst
> > rs.Close
> >
> > End If
> >
> > End Sub
> >
> > the combo box gets called when the form is loaded. at the moment, it
only
> > diplays 1 paper title, but some countries have more then 1.
> >
> > thanx
> >
> > devin<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: SQL- using lst box to gatehr info for a specidi field. |
|
| Back to top |
|
 |  |
| Related Topics: | sql query returns in wrong format - Hi, Hope someone can help me with this. I have MS SQL 2000 database where i have Table "PriceList" and there a column "Pricemk" wich is data type "money". All data in this column is in form "10001,35". So why when...
arrays - is there a way to concatenate the contents of an array (looping through the array) and storing each item in a comma delimited string? Thanks!
DataReport PageBreak - Hi everyone, I would like to know how to force pagebreak in a datareport for example after 5 records printed. Thank you all
Possible Use of a Cursor - I have a complex query that I hope I can explain it well enough for everyone to understand. I have a table that contains information for work instructions. Contained in the table are "MACHINE_PROC" these are groupings of machining processes....
Scroll Bars - Is there a way to find the size of scrollbars on a system using Visual Basic 6.0? I know how to look and change them on the display properties, but I don't know how to access that information from within Visual Basic. |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|