Combo-box and SQL

G

Guest

Help Please
I am using combo boxes to allow user to select personnel from a table of members. Alternately a non-member (guest) may be entered (not limited to list). The members table also includes a unique member ID number. I would like to allow entry of a member ID number and have such an entry (using if isNumeric(cboP1)=True) result in a lookup from the table to acquire and display the member's name rather than the member ID number.

A simple parameter query gets the name all right, but I am not sure as to how to populate the combo-box (and therefore the field) with the member's name

Thanks in advance
 
S

Steve Schapel

Bob,

I think code like this, on the AfterUpdate event of your combobox, will
do it...
If IsNumeric(Me.cboP1) Then
Me.cboP1 = Nz(DLookup("[MemberName]", "Members", "[Member ID]=" &
Me.cboP1), "No such member")
End If

The Row Source of the combobox is presumably the Members table, and the
Bound Column of the combobox should be the MemberName column.
 

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