Query Criteria Error

ilyavol

New member
Local time
Today, 20:21
Joined
Jun 25, 2001
Messages
5
Here's my code for creating a query criteria that is passed from a for field to a report. What am I doing wrong?

Dim stDocName As String
Dim strLinkCriteria As String

strLinkCriteria = "[Date Closed] = >#" & Me![fromDate] & "# And <#" & Me![toDate] & "#"

stDocName = "rptSterling2"
DoCmd.OpenReport stDocName, acNormal, , strLinkCriteria

I get a "Syntax error, missing operator." However if I manually put the following into the criteria field of the query then it works. ">#7/1/2001# And <#9/30/2001#" (no quotes).

Thanks in advance!
 
You must include the field qualifier again:

strLinkCriteria = "[Date Closed] =>#" & Me![fromDate] & "# And [Date Closed]<#" & Me![toDate] & "#"

Careful with spaces between the = and >!

HTH
 
Thanks a bunch! I'll give it a shot!
 

Users who are viewing this thread

Back
Top Bottom