PDA

View Full Version : Solved: query not working right



Trevor
03-08-2008, 08:56 PM
this is supose to select only those records where the state = Me.state and the records date that is between Me.Datefrom and Me.DateTo
but when I added the date argument to the where clause it seems to bypass my state = Me.state argument and only produces all the records between those dates

Set loRst = CurrentDb.OpenRecordset("SELECT * FROM [VMSU-CLT] WHERE" _
& " [State]= '" & Me.[State] & "' & [Date]>= '" & Me.[DateFrom] & "' & [Date]<= '" & Me.[DateTo] & "';")
what am I doing wrong here?

orange
03-09-2008, 05:47 AM
this is supose to select only those records where the state = Me.state and the records date that is between Me.Datefrom and Me.DateTo
but when I added the date argument to the where clause it seems to bypass my state = Me.state argument and only produces all the records between those dates

Set loRst = CurrentDb.OpenRecordset("SELECT * FROM [VMSU-CLT] WHERE" _
& " [State]= '" & Me.[State] & "' & [Date]>= '" & Me.[DateFrom] & "' & [Date]<= '" & Me.[DateTo] & "';")
what am I doing wrong here?

I'd try this:

Set loRst = CurrentDb.OpenRecordset("SELECT * FROM [VMSU-CLT] WHERE" _
& " [State]= '" & Me.[State] & "' AND [Date]>= #" & Me.[DateFrom] & "# AND [Date]<= #" & Me.[DateTo] & "#;")

Trevor
03-09-2008, 08:20 PM
thanks , that worked