Use for double quotes

mahmudich

Registered User.
Local time
Tomorrow, 07:35
Joined
Feb 10, 2003
Messages
73
Hi guys!

Does anyone could explain me how should I use double quotes sings “” in a command lines, for example:

If IsNull(DLookup("[WeekID]", "[tbl_Weeks]", "[WeekID] = " & Me![cmb_Week] & "")) Then …

I know that was correct syntax, but I can’t get why at the end of DLOOKUP I had to use double quotes twice?


Thank you
 
By using the two inverted commas in your criteria section of the DLookup() you are effectively adding to the string which is why you are requiring two.

The syntax you want is:

Code:
"[WeekID] = " & Me![cmb_Week]))

although what you have is just the exact same with a null string being appended to the end.

If the field you were after was a text field you would build your criteria like this:

Code:
"[WeekID] = '" & Me![cmb_Week] & "'"))

By adding the apostrophe to either side of the text we requir we are indicating that the value is a string.

However, there may be occassions where the field we are searching on is a surname and because some surnames have apostrophes in them then the string would terminate at that apostrophe rather than the end one.

On these occasions we can replace each apostrophe with two extra inverted commas.

Code:
"[WeekID] = """ & Me![cmb_Week] & """"))
 

Users who are viewing this thread

Back
Top Bottom