How to make bound cbo be blank Form open (1 Viewer)

Zydeceltico

Registered User.
Local time
Today, 10:28
Joined
Dec 5, 2017
Messages
843
In this DLookup
'JDRAW change the constraint/where to use string - quotes on CoilNumber
' This does not error now.
txtCoilNumber_PK = DLookup("CoilNumber_PK", "tblCoils", "[CoilNumber] = '" & Me.txtCoilNumber & "'") 'this line errors 2471 not any more

I hope this resolves Issue #1, and you have #2 working ---so all seems ok at the moment.

JDraw - That did the trick! Thanks!

I need to study DLOOKUP some more because I was confused about the final argument. (i.e., & Me.txtCoilNumber &...)

I will look at OPTION EXPLICIT and try to wrap my mind around it.
 

jdraw

Super Moderator
Staff member
Local time
Today, 10:28
Joined
Jan 23, 2006
Messages
15,364
Tim,
The issue with the statement was with the use of delimiters
-numbers require no delimiters... eg = 38
-dates require # delimiters.. eg = #1\26\2020#
-strings require quote delimiters ..eg = "John"

In this case you had to enclose coilNumber value in a single quotes while keeping the vba code within double quotes.
Code:
txtCoilNumber_PK = DLookup("CoilNumber_PK", "tblCoils", "[CoilNumber] = '" & Me.txtCoilNumber & "'")

As for Option Explicit, it is a "no brainer" --Access will tell you if a variable is misspelled or not dimensioned/declared.
 

Users who are viewing this thread

Top Bottom