Combo's and Queries

  • Thread starter Thread starter Nudicles
  • Start date Start date
N

Nudicles

Guest
Quick question for you non-newbs out there...

I have two combo's on the same form, cboFName, cboLName. Trying to make some kind of a cascading combo thing, where when a cboLName is selected, my cboFName will be filled with All the firstname's that share that common last name. All of this data is on the same table, and here's my SQL for the queries at the moment:

SELECT DISTINCT tblContacts.LastName
FROM tblContacts
ORDER BY tblContacts.LastName;

SELECT tblContacts.LastName, tblContacts.FirstName
FROM tblContacts
WHERE (((tblContacts.LastName)=Forms!test!cboLName))
ORDER BY tblContacts.FirstName;

For some reason, the first query for my cboLName (although it works as a stand alone query) gives me a combo box full of blank names. Besides that, can anyone see anything wrong with my code?

Thanks,
Paul
 
Try this!!

First Combo - SELECT tblContacts.Lastname FROM tblContacts;

Second Combo - SELECT tblContact.Lastname, tblContact.Firstname FROM tblContacts WHERE [Firstname]=[cboLastname]; 'or whatever your combo is called'

Also create an After Update Prcedure for the first combo:

Private Sub cboLastName_AfterUpdate()
Me.cboFirstName.Requery
End Sub

Hope this helps...
 
For Some reason, still not getting anything in my first combo box, cboLName... very peculiar. Do you think it has anything to do with the size of my data? I have around 2.5k entries... probably about 1.5k unique last names.

Thanks
Paul
 
The First combo is a simple select query, so it should display your records...

Not sure about the size thing.
 
aha... had to do with the formatting... number of columns, etc.. fixed.

Thanks swed, code works :)
 

Users who are viewing this thread

Back
Top Bottom