stlinkcriteria from a listbox

gadjet

Registered User.
Local time
Today, 14:12
Joined
Jan 21, 2008
Messages
45
Hi,
I have a form with several multi column listboxes, these are populated using a query supplying the top 1 record from a table (based on some criteria).

They work fine but when I added a button (for each list box) to open a detailed form to edit the data from the record I ran into problems.

The add button wizard created the stlink criteria but whenever I tried it I got an error :

Syntax error (missing operator) in query expression '[ID]='

The code generated is
Code:
    stLinkCriteria = "[ID]=" & Me![List1]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

For some reason the ID from the list box, which is the bound column for the list box is not seen by the code, any ideas why?

I have worked around by using another hidden text box (for each listbox)which uses Dlookup to get the ID from the table.

I've tried using list1.column(1) without success...!!!

Any pointers will be much appreciated.

Gadjet
 
have you tried

list1.SelectedItem.Value ?
 
have you tried

list1.SelectedItem.Value ?

Rainman89
Thanks for the reply.

No I haven't but there isn't anything selected at the time I click the button so I don't think it will work.

I think my problem is something to do with referencing the ID value from the listbox, it work if I reference a value in a textbox but not from the list box???

Cheers
 
So you are trying to reference a listbox that doesnt have anything selected in it?

Im confused why are you clicking the button without selecting something from the listbox?
 
So you are trying to reference a listbox that doesn't have anything selected in it?

Im confused why are you clicking the button without selecting something from the listbox?

DUH! You have hit the nail on the head, my problem was I forgot that even thought my list box can only ever have one record it will still need to be selected before I can get access to the ID value.

I will stick with the workaround as I have 8 single row multi column list boxes to display the latest entries for 8 different criteria from the same table.

I thought this would be quicker than generating 56 text boxes with Dlookups.

Thanks for your help.

Gadjet
 

Users who are viewing this thread

Back
Top Bottom