Syntax Question about Between

  • Thread starter Thread starter Joe Cilinceon
  • Start date Start date
J

Joe Cilinceon

What is the proper syntax to send the following:

Between [beginning date:] And [ending date:] Now this is working fine in a
stand alone report.

However I'm getting a 'missing operator in query expression' error when I
set it up as below:

strWhere = "[StartDate] = Between " & txtStartDate & " And " & txtEndDate

DoCmd.OpenReport "Move In Report", acViewPreview, , strWhere
 
Drop the equal sign:
strWhere = "[StartDate] Between #" & txtStartDate & "# And #" & txtEndDate
& "#"

The # sign as delimter around the literal date values in the string is also
worthwhile.
 
Try:

strWhere = "[StartDate]" & " Between " & Format(Me.txtStartDate, "\#m\/d\/yyyy\#") _
& " And " & Format(Me.txtEndDate, "\#m\/d\/yyyy\#")
 
Thanks Allen it worked I figure the # would be needed as it was in the other
but the "=" is what was getting me. Thanks again

--

Joe Cilinceon


Allen Browne said:
Drop the equal sign:
strWhere = "[StartDate] Between #" & txtStartDate & "# And #" & txtEndDate
& "#"

The # sign as delimter around the literal date values in the string is also
worthwhile.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Joe Cilinceon said:
What is the proper syntax to send the following:

Between [beginning date:] And [ending date:] Now this is working fine in a
stand alone report.

However I'm getting a 'missing operator in query expression' error when I
set it up as below:

strWhere = "[StartDate] = Between " & txtStartDate & " And " &
txtEndDate

DoCmd.OpenReport "Move In Report", acViewPreview, , strWhere
 
Thanks Jeff that also worked fine. g

--

Joe Cilinceon


Jeff Conrad said:
Try:

strWhere = "[StartDate]" & " Between " & Format(Me.txtStartDate, "\#m\/d\/yyyy\#") _
& " And " & Format(Me.txtEndDate, "\#m\/d\/yyyy\#")

--
Jeff Conrad
Access Junkie
Bend, Oregon

What is the proper syntax to send the following:

Between [beginning date:] And [ending date:] Now this is working fine in a
stand alone report.

However I'm getting a 'missing operator in query expression' error when I
set it up as below:

strWhere = "[StartDate] = Between " & txtStartDate & " And " & txtEndDate

DoCmd.OpenReport "Move In Report", acViewPreview, , strWhere
 
Excellent, glad to help.

--
Jeff Conrad
Access Junkie
Bend, Oregon

Joe Cilinceon said:
Thanks Jeff that also worked fine. g

--

Joe Cilinceon


Jeff Conrad said:
Try:

strWhere = "[StartDate]" & " Between " & Format(Me.txtStartDate, "\#m\/d\/yyyy\#") _
& " And " & Format(Me.txtEndDate, "\#m\/d\/yyyy\#")

--
Jeff Conrad
Access Junkie
Bend, Oregon

What is the proper syntax to send the following:

Between [beginning date:] And [ending date:] Now this is working fine in a
stand alone report.

However I'm getting a 'missing operator in query expression' error when I
set it up as below:

strWhere = "[StartDate] = Between " & txtStartDate & " And " & txtEndDate

DoCmd.OpenReport "Move In Report", acViewPreview, , strWhere
 
Back
Top