Syntax Question about Between

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
 
A

Allen Browne

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.
 
J

Jeff Conrad

Try:

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

Joe Cilinceon

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
 
J

Joe Cilinceon

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
 
J

Jeff Conrad

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top