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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

between...and operation help........ sql newbie

Status
Not open for further replies.

andrest

Programmer
Jul 25, 2002
20
CA
Hi I'm trying to query a database using a BETWEEN operation to choose between to dates.

adoAllJobs.CommandType = adCmdText
adoAllJobs.RecordSource = "SELECT Jobs.JobNumber,Jobs.Date, Clients.BussinessName, Jobs.ProjectName, Jobs.Salesman, Jobs.SubTotal, Jobs.GST, Jobs.Total, Jobs.Balance FROM Jobs, Clients WHERE Jobs.ClientID = Clients.ClientID AND Jobs.Date BETWEEN #8/1/2002# AND #8/31/2002#"
adoAllJobs.Refresh

But it does not work when the dates are replaced by variables. Something like this......

adoAllJobs.CommandType = adCmdText
adoAllJobs.RecordSource = "SELECT Jobs.JobNumber, Jobs.Date, Clients.BussinessName, Jobs.ProjectName, Jobs.Salesman, Jobs.SubTotal, Jobs.GST, Jobs.Total, Jobs.Balance FROM Jobs, Clients WHERE Jobs.ClientID = Clients.ClientID AND Jobs.Date BETWEEN #FisrtDayOfMonth# AND #LastDayOfMonth#"
adoAllJobs.Refresh

can someone give me a hand.

andrest
 
I think you might want to make a slight change in your syntax. Something like the following

" ...BETWEEN #" & FisrtDayOfMonth& "# AND #" & LastDayOfMonth & "#"

Your original syntax put the name of variable in the SQL statement, and not the value of the variable. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Ok... i finally got it going.... thanks guys....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top