What wrong with this listbox code?

daninthemix

Registered User.
Local time
Today, 07:58
Joined
Nov 25, 2005
Messages
41
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Logins"
stLinkCriteria = "[ID]=" & "'" & Me![lstLogins] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

This code is on the doubleclick event.

lstLogins is sourced from this: SELECT Logins.[ID], Logins.[Login for] FROM Logins WHERE (((Logins.Customer)=[forms]![customers]![customer]));

When i run it I get a VB error "The OpenForm action was cancelled", and the debugger stops on the last line above (Do.Cmd...)

Any ideas why?

I know [ID] is a long integer, but I tried formatting it with Str just in case and it made no difference :(
 
Hey Dan,

If ID is a number then try this instead:

stLinkCriteria = "[ID]=" & Me![lstLogins]


HTH,
Shane
 
Thanks a million Shane - that's sorted it!
 

Users who are viewing this thread

Back
Top Bottom