I have the following 3 tables:
Clients, which has a numeric PK field called CLIENT_ID
Languages, which has a numeric PK field called LANGUAGE_ID
Client_Languages, which has a unique PK and foreign key fields
CLIENT_ID and LANGUAGE_ID
Clients and Languages each have a one-to-many relationship with
Client_Languages.
My form displays all the information in the Clients table, it also
contains a multi-list box containing all the values in the Languages
table.
When I cycle through my records I want to query the Client_Languages
table based on Client_ID and highlight each entry in multi-list box for
the current client record.
I currently have this function which does not work at all:
Private Sub Form_Current()
'Clear out any previous values
For x = 0 To Me!Languages_Spoken.ListCount - 1
Me!Languages_Spoken.Selected(x) = False
Next x
If Me![client id] > 0 Then
'Populate list box with saved values (if any exist)
For x = 0 To Me!Languages_Spoken.ListCount - 1
If Me!Languages_Spoken.ItemData(x) = DLookup("LANGUAGE_ID",
"CLIENT_LANGUAGES", "CLIENT_ID = " & Me![client id]) Then
Me!Languages_Spoken.Selected(x) = True
Next x
End If
End Sub