multi-list box help!

  • Thread starter Joe Christopher via AccessMonster.com
  • Start date
J

Joe Christopher via AccessMonster.com

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
 
M

MacDermott

Please don't post the same message to different groups like this!
I answered this in another group -
hope you can find it, because I sure don't recall which one it was!

In the future, please put all the groups you're posting to in the To: line
of a single post.
That way all answers will appear together in all the groups, and respondents
(we're all volunteers) won't overlap.

Joe Christopher via AccessMonster.com said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top