2 combos in a form

espenzaal

New member
Local time
Today, 21:45
Joined
Mar 1, 2006
Messages
6
Hello!
I got a database with two tables in it.
Site table has following fields: ID,SiteID
Customer table got following fields: DropID, Dropname, SiteID.

These two tables are connected in a One-to-Many relationship.

I got a form with two combo's . I want to select "SiteId" from the first combo and based on the selection i do in the first combo i want the second combo to just show the relevant data (dropid and dropname) for that "Site".
I got one table named "Site" and one table called "Cutomers".

The database contains alot of other stuff and much of it is in norwegian so im not sure how usefull it would be if i posted the mdb here but if someone think its usefull then i will post it.

I can choose from the combo boxes and it works fine but the connection between the two are not working. Not matter what i choose in combo1 i get all recrods in combo2.

Can anyone help?

wbr
Espen
 
I hope I can help 'cause I faced similar problem.

Open the 'properties' panel of the relevant combo-box and on the 'data' panel (properties>data) give the right query in the row source field (where the filter is the one of the field on the form)

If you'd like to keep these queries refreshed see
http://www.blueclaw-db.com/comboboxlist/access_dependent_dropdown_list.htm
or
http://www.access-programmers.co.uk/learning2/TipsForms.htm
and some material on this forum
for example
VBasic reference of record stepping
continous refreshing
(I was inspecting in this issue...:))

BR
 
This technique is known as cascading combos. Plenty of info in these forums on the subject.
 
Thanks for the replies.
I seems to be very close. My problem is that i do not know what should be behind the boxes. The Procedure After update on the two combos.

I have added the Row sources like suggested.
The First Combo shows SiteId fine but the code that should update the second combo is what i need i think.
Right now when i select in first combo the second combo is jumping to right record but i cant select anything from the second combo.
A message says the recordset cant be updated. I have figured out that this can be because of the Control source. Other solutions i have seen doesnt use controlsource but its the closest i have come :)

The code behind the combo i have now is what was made when i made the combo so i figure this is where the job is to fix this.


This is how the code behind Box 1 looks like. (Kunder is Customers)
Private Sub SiteID_box_AfterUpdate()
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Kunder].[SiteId] = '" & Me![SiteID_box] & "'"
Me.Bookmark = rs.Bookmark
End Sub

The second box looks alike just with different names

Can anyone help?
I have worked so long with computers that i hate to call myself a newbie but in access i really am ;)
 
I have found ou how to solve my problem thanks to Robert88's reply to another user here in the forum.
He suggested this link
I used example 2.
thanks alot :D
 

Users who are viewing this thread

Back
Top Bottom