String Crawling Thing (1 Viewer)

st3ve

Registered User.
Local time
Today, 17:45
Joined
Jan 22, 2002
Messages
75
I am having problems with placement of delimiters around the criteria part of the 2 expressions below:-

Place1 = "CCYP" ....CCYP is an OrgName listed in tblkOrgEmailAddresses

(1) ' WORKS OK
fred = (DLast("ReportName", "tblkOrgEmailAddresses", "OrgName = '" & "CCYP" & "'"))

' What I want to do is replace the hard coded name CCYP with a placeholder name eg:-
fred = (DLast("ReportName", "tblkOrgEmailAddresses", OrgName = Place1))

(2) ' WORKS OK
DoCmd.OpenReport fred, acPreview, "", "[CentreNamed]=""CCYP"""

I want to do is the same sort of thing here in the filter expression ie. replace the hard coded name CCYP with a placeholder name.

eg. ... DoCmd.OpenReport fred, acPreview, "", "[CentreNamed] = Place1.

Any ideas? Thanks for looking.
Steve.
 

Mile-O

Back once again...
Local time
Today, 17:45
Joined
Dec 10, 2002
Messages
11,316
Firstly:

Code:
fred = (DLast("ReportName", "tblkOrgEmailAddresses", "OrgName = '" & "CCYP" & "'"))

Can simply be written as:

Code:
fred = DLast("ReportName", "tblkOrgEmailAddresses", "OrgName = 'CCYP'")


If you have a Numeric variable: (INteger, Long, SIngle, Double, Currency, Boolean)

Code:
fred = DLast("ReportName", "tblkOrgEmailAddresses", "OrgName = " & [i]variable[/i])

If you have a Text variable: (String)

Code:
fred = DLast("ReportName", "tblkOrgEmailAddresses", "OrgName = """ & [i]variable[/i] & """")

If you have a Date variable: (Date)

Code:
fred = DLast("ReportName", "tblkOrgEmailAddresses", "OrgName = #" & [i]variable[/i] & "#")
 

st3ve

Registered User.
Local time
Today, 17:45
Joined
Jan 22, 2002
Messages
75
String Crawling Thing now Driving beautifully

Thanks Mile-o,

I thought i had tried all the combinations, but hadn't got as far as this number of sets of ""s!!

DoCmd.OpenReport fred, acPreview, "", "[CentreNamed] = """ & Place1 & """" did the trick.
 

Mile-O

Back once again...
Local time
Today, 17:45
Joined
Dec 10, 2002
Messages
11,316
I tend to use """ and """" because there are times when a string may contain a '.

"" creates a " within the string rather than acting as a delimiter.
 

Users who are viewing this thread

Top Bottom