Help With Query Problem (1 Viewer)

n00b

Registered User.
Local time
Today, 05:19
Joined
Jan 28, 2003
Messages
12
Thanks for taking the time to read this Post i am basically very new to this and need some help regd my project please

in brief what i am trying to do is

i got DB Combo 1 = gets value from data1 =Hospital Name Table
DBCombo 2 = gets value from data 2 = Patient Names

what i am trying to accomplish here is that when i choose Hospital name from db combo1 then i want the dbcombo2 list to get refreshed and show me patient nams pertaining to the hospital only then i have a grid which basically reads off data2 and will display all results .. Now what i cant figure where is the Query code is gonna go and what it should be i know its pretty basic but like my User Name am just a n00b ....Btw the name of the table is (Notes) which contain [location] [PatientName] and [Notes] .. Thanks in Advance
 

Mile-O

Back once again...
Local time
Today, 05:19
Joined
Dec 10, 2002
Messages
11,316
On the AfterUpdate() event of the hospital names combobox you can put a line of code to change the RowSource of the patients' names combox and then Requery that.


I could go into it further but not yet as there is a questions I've got to ask.

Have you created a one-to-many relationship between your hospital table and your patient table?
 

n00b

Registered User.
Local time
Today, 05:19
Joined
Jan 28, 2003
Messages
12
Thanks Mile for your reponse

As of yet i havent made any relationships between tables at all

and on the comboboxes there is no <b>Afterupdate</b> but i can use <b>Change</b> instead. I will wait for your reponse in this matter until then i will use your idea to see what i can accomplish on my own . Thanks
 

Mile-O

Back once again...
Local time
Today, 05:19
Joined
Dec 10, 2002
Messages
11,316
There is an After Update event: just under Before Update. It should be the second event listed in a combobox's events; just a couple above On Change.

Once you have your relationship in order you'll be changing the patient name combobox's RowSource to something like:

Code:
"SELECT [Patient] FROM tblPatients WHERE [Hospital] = '" & cboHospital & "';"
 

n00b

Registered User.
Local time
Today, 05:19
Joined
Jan 28, 2003
Messages
12
Mile i am following what you are saying but i guess we have a misunderstanding here . i am using VB 6 for the application with a MS Access DB in the back end and using dbcombo dropdown or combo boxes neither have a update or afterupdate but what it does have is Change and that i think works just as good except it checks that in form load up too here is what my sub looked like

Dim strSQL As String

strSQL = "select [PatientName] From [Notes] WHERE [Location] ='" & DBCombo2 & "';"
DBCombo1.RowSource = strSQL


i get an error saying object required and when i look up the highlite text on
line 2 (dbCombo1.rowsource=strSQL) it says dbCombo1=nothing
 

Mile-O

Back once again...
Local time
Today, 05:19
Joined
Dec 10, 2002
Messages
11,316
Since this is an Access forum and you never said in your first post you were using VB6, I could only assume you were using access. No problems there then; OnChange is fine.

It looks like you have your DbCombo1 & 2 the wrong way around as you said in yur first post that DbCombo1 was for the hospital name, and if that holds true in the code you posted you are trying to change the rowsource of the combobox to where the Location is equal to a patient's name - although it probably won't appear that way.
 

n00b

Registered User.
Local time
Today, 05:19
Joined
Jan 28, 2003
Messages
12
Yes Mile you are right i am learning from my mistakes that next time better plan your projects .

i got dbcombo 2 as hospital name
and dbcombo 1 as patient name


Sorry about any confusions .
 

Users who are viewing this thread

Top Bottom