Query table sub field in listbox

Jerome

Registered User.
Local time
Yesterday, 18:49
Joined
Jul 21, 2009
Messages
77
Hello,

I have a main table that has a field that is linked to sub table (using lookup, set row source to correct table using SELECT statement that selects two columns out of the sub table (e.g. the ID and Name Column)).

When I run a query on the main table I would like to be able to set the column that should be returned (e.g. the Name column). Currently when I run a query on the main table to be displayed in a listbox the first column of the sub table is always retrieved.

Any advice?

Thanks in advance and with best regards.
 
Columns in list boxes and combos are numbered starting at zero.
So the second column is Column(1).
However you can't use that in a query.

Instead use a string variable or a tempvar such as
strName=Forms!FormName.listboxname.Column(1)

I then create a function to retrieve that variable
GetName=strName

Then filter your 'Name' field using the function (or the tempvar if used)

FYI Name is a reserved word in Access and shouldn't be used for field names
 

Users who are viewing this thread

Back
Top Bottom