Selecting item from combo box

yhgtbfk

Registered User.
Local time
Today, 23:59
Joined
Aug 30, 2004
Messages
123
Not sure what to search for so I thought Id write a new post:

I have a combo box which selects 3 items-

Primary key, Surname, Firstname

After an item is selected, the fields are populated according to the item.

Since there will be many records, it would be nice if the user can begin typing the surname and have predictive text, so the three items should then be-

Surname, Firstname, Primary key

So my question is, how do I get at the primary key if it is not selected?

myText = dlookup("myValue", "myTable", "primarykey = '" & ???? & "'")

If this does not make sense, what I am trying to say is:

The surname is selected, but I want to do a calculation based on the primary key so I get all the data associated with that user. I cant use the surname because there are duplicates.

Thank you
 
What I gather from your post is that you want the left hand most column to contain the surname, but by doing that it messes up your code, in that your "dlookup" will not find the primary key. If that's the case then :-

Open the properties window of your combo box, Under the data tab, open the query designer grid from the row source line and select the primary key as your far left hand column, you should now have four columns in your query, the new primary Key columb you have just added, and the surname, firstname and a primary key value. As you have added an extra column you will have to change the column count. To do this select the "format" tab and in the column count row, change the value to four. Put the following in for your column widths, 0cm;2.542cm;2.542cm;2cm notice that the first width is zero, this effectively hides the column from view, but allows your other code to find a value.

I notice that you are displaying the primary key value in your combo box, this is not generally necessary, unless you have some particular reason for doing it.
 
Worked perfectly. Thank you.
 

Users who are viewing this thread

Back
Top Bottom