View Full Version : Query Criteria Error


ilyavol
10-02-2001, 08:02 AM
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!

pdx_man
10-02-2001, 09:46 AM
You must include the field qualifier again:

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

Careful with spaces between the = and >!

HTH

ilyavol
10-02-2001, 05:22 PM
Thanks a bunch! I'll give it a shot!