SQL statement question?

F

fox

It seems like I have SQL code problem.
I use vba code to make a query. strSelect is string
strSelect = "Select [RecordDate] " & _
"From [Record] " & _
"Where [Company] = '" & Me.SelectCompany.Value & "' And " & _
" [RecordDate] < #" & Me.EndDate.Value & "# And
[RecordDate] > #" & Me.StartDate.Value & "#" & _
"Order by [RecordDate] DESC"
I need it keeps the record data which between the date, but I think the
StartDate and EndDate code is wrong. How should I write it?
Thank you.

Fox
 
O

Ofer

You might get an error because there is no space between the last # and the
Order by.

Try this
strSelect = "Select [RecordDate] " & _
" From [Record] " & _
" Where [Company] = '" & Me.SelectCompany.Value & "' And "
& _
" [RecordDate] Between #" & Me.EndDate.Value & "# And " & _
" #" & Me.StartDate.Value & "#" & _
" Order by [RecordDate] DESC"
 
F

fox

It's works, thank you.

Ofer said:
You might get an error because there is no space between the last # and the
Order by.

Try this
strSelect = "Select [RecordDate] " & _
" From [Record] " & _
" Where [Company] = '" & Me.SelectCompany.Value & "' And "
& _
" [RecordDate] Between #" & Me.EndDate.Value & "# And " & _
" #" & Me.StartDate.Value & "#" & _
" Order by [RecordDate] DESC"
--
\\// Live Long and Prosper \\//
BS"D


fox said:
It seems like I have SQL code problem.
I use vba code to make a query. strSelect is string
strSelect = "Select [RecordDate] " & _
"From [Record] " & _
"Where [Company] = '" & Me.SelectCompany.Value & "' And " & _
" [RecordDate] < #" & Me.EndDate.Value & "# And
[RecordDate] > #" & Me.StartDate.Value & "#" & _
"Order by [RecordDate] DESC"
I need it keeps the record data which between the date, but I think the
StartDate and EndDate code is wrong. How should I write it?
Thank you.

Fox
 
Top