Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Between Dates query Problem

Status
Not open for further replies.

wolfbrother

Technical User
Jun 14, 2002
10
US
Good morning all, having a problem getting this query to come out correctly. I've never written a between query like this before and am not sure I'm getting the operators correct. Please check me on this and let me know what I'm doing wrong.
Thanks in advance.

David.
_________________________________________________
Code used, it's extracting the entered dates from text boxes on a form.

Dim strsql As String
Dim strbegdate As String
Dim strenddate As String
strbegdate = Me.txt_beginningdate
strbegdate = "'" & strbegdate & "'"

strenddate = Me.txt_endingdate
strenddate = "'" & strenddate & "'"


strsql = "SELECT [date],[censusid] FROM [quotelog] WHERE [date] =" & " between " & begdate & " And " & enddate
 
Dim strsql As String
Dim strbegdate As Date
Dim strenddate As Date
strbegdate = Me.txt_beginningdate

strenddate = Me.txt_endingdate


strsql = "SELECT [date],[censusid] FROM [quotelog] WHERE [date] Between #" & strbegdate & "# And #" & strenddate & "#"


Try this.
 
WORKED WONDERFULLY!
Thanks Paul, a very valuable lesson.
 
One of the tricks I use to debug strings like that is to use the Debug window. I write a line

strsql = "SELECT [date],[censusid] FROM [quotelog] WHERE [date] Between #" & strbegdate & "# And #" & strenddate & "#"
Debug.Print strsql

It will show you how Access is seeing the values you are trying to pass to it.

Glad it helped.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top