My Assistant
![]() ![]() |
|
|
Apr 3 2012, 07:45 PM
Post
#1
|
|
|
UtterAccess Veteran Posts: 408 From: Tennessee |
Can someone be so kind as to help in setting the quotation marks correctly in this line of code:
CODE res = DLookup("[RoomRequestID]", "qryReservationsMC", "[OrganizationIndividual] = """ & strOrganizationIndividual & """ AND [FunctionType] = " & iFunctionType & " AND [StartDate] = " & dtCriteria1) Thank you. |
|
|
|
Apr 3 2012, 07:49 PM
Post
#2
|
|
|
Utterly Yorkshire and Forum/Wiki Editor Posts: 15,885 From: Devon UK |
Hi
Guessing that the data types are text, numerical and date/time it would be CODE res = DLookup("[RoomRequestID]", "qryReservationsMC", "[OrganizationIndividual] = '" & strOrganizationIndividual & "' AND [FunctionType] = " _ & iFunctionType & " AND [StartDate] = #" & dtCriteria1 & "#") |
|
|
|
Apr 3 2012, 07:51 PM
Post
#3
|
|
|
UtterAccess Guru Posts: 752 From: Silver Spring Maryland, USA |
CODE DLookup("[RoomRequestID]", "qryReservationsMC", "[OrganizationIndividual] = " & strOrganizationIndividual & " AND [FunctionType] = " & iFunctionType & " AND [StartDate] # "& dtCriterial & "#") Looks right... EDIT: Ah, missed the single quotes. This post has been edited by Scot: Apr 3 2012, 07:52 PM |
|
|
|
Apr 3 2012, 07:58 PM
Post
#4
|
|
|
UtterAccess Veteran Posts: 408 From: Tennessee |
Thanks Alan....that fixed it!
|
|
|
|
Apr 3 2012, 08:01 PM
Post
#5
|
|
|
Utterly Yorkshire and Forum/Wiki Editor Posts: 15,885 From: Devon UK |
|
|
|
|
Apr 3 2012, 09:49 PM
Post
#6
|
|
|
UtterAccess Editor Posts: 15,978 From: Northern Virginia, USA |
I know you have found a solution to your immediate issue, but I thought it would be appropriate to relay this concept that goes deeper than a one time fix, because if your literal string has a single hash, you will be right back at square one. So here is the concept: Double up your delimiter in the string being sought.
Example: If you use the single hash (') as your literal string delimiter in your SQL statement (or filter argument of a DLookup), then double-up the single hash in the string being sought ... CODE "SELECT * FROM someTable WHERE someTextField = '" & Replace(stringVariable,"'","''") & "'" Or with DLookup() CODE DLookup("[RoomRequestID]", "qryReservationsMC", "[OrganizationIndividual] = '" & Replace(strOrganizationIndividual,"'","''") & "'") If you use the double quote (") as your literal string delimiter in your SQL statement (or filter argument of a DLookup), then double-up the double quote in the string being sought ... CODE "SELECT * FROM someTable WHERE someTextField = """ & Replace(stringVariable,"""","""""") & """" Or with DLookup() CODE DLookup("[RoomRequestID]", "qryReservationsMC", "[OrganizationIndividual] = """ & Replace(strOrganizationIndividual,"""","""""") & """")
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 25th May 2013 - 03:40 AM |