SQL statement question?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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"
 
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
 

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

Back
Top