Question combobox gives same value for all records

Siggi

New member
Local time
Today, 15:02
Joined
Jun 25, 2009
Messages
4
Dear experts,

Woul like to call in your help and expertise on a problem I can't figure out.
In my database I have a form Trade with 5 comboboxes: Supplier, Country, Port, Equipment and Brand. Here I can enter which supplier is offering which Equipment of which brand in which country/port.
I'm trying to link the Country and Port comboboxes sothat when you make a selection in the Country combobox, the Port combobox is filtered showing the available selection of ports for that country.
I have below codes but when running, the value in the Country field is showing the same value in all the records(???), when I select another record I get the value for that record shown in all the Country fields off all the other records!???


I'm doing something wrong but can't find the mistake, can anybody help me out? Thanks. Kind regards, Siggi.

Private Sub Form_Current()
If Me.portID <> 0 Then
Me.Keuzeland = DLookup("CountryID", "TblPort", "portID=" & Me.portID)
Me.portID.RowSource = "SELECT portID, PortName FROM TblPort WHERE CountryID =" & Me.Keuzeland & " ORDER By PortName"
Else
Me.Keuzeland = ""
Me.portID.RowSource = ""
End If
End Sub

Private Sub KeuzeLand_AfterUpdate()
Me.portID = Null
Me.portID.RowSource = "SELECT PortID, PortName FROM TblPort WHERE CountryID =" & Me.Keuzeland & " ORDER By PortName"
Me.Refresh
End Sub
 
Me.Keuzeland = DLookup("CountryID", "TblPort", "TblPort.portID = Me.portID")
 
Put Me!ComboBox.Requery before the End Sub to reflect the change you made in the rowsource of the control
 
Thank you both for your swift response and advice.
Unfortunately though the problem still persists. I'm now getting following error.
runtime error '2001' you cancelled the previous operation

Any furhter suggestions?
Thanks,
Rgds, Siggi
 

Users who are viewing this thread

Back
Top Bottom