between

  • Thread starter Thread starter mission2java_78
  • Start date Start date
M

mission2java_78

Guest
Dynamically generating an SQL string for a reports record source. If I have:
mySQL = mySQL & " BETWEEN #" & Forms!frmReportsSwitchboard!txtBeginDate & " AND #" & Forms!frmReportsSwitchboard!txtEndDate

do I need to add an AND before between? Or a where ? because I cant seem to get the query correct it says missing syntax.
Thanks,
Jon
 
Don't you have to enclose the date literals (that is the form txt string, right?) in "#" characters?

Try:

mySQL = mySQL & " BETWEEN #" & Forms!frmReportsSwitchboard!txtBeginDate & "# AND #" & Forms!frmReportsSwitchboard!txtEndDate & "#"

You may have to fiddle wid'dem quotes...

HTH

Doug.
 
I forgot to base it on a field :).
If Not IsNull(Forms!frmReportsSwitchboard!txtBeginDate) And Not IsNull(Forms!frmReportsSwitchboard!txtEndDate) Then
If vsnCond = False Then
mySQL = mySQL & " WHERE OpenDate BETWEEN #" & Forms!frmReportsSwitchboard!txtBeginDate & "# AND #" & Forms!frmReportsSwitchboard!txtEndDate & "#"
Else
mySQL = mySQL & " AND OpenDate BETWEEN #" & Forms!frmReportsSwitchboard!txtBeginDate & "# AND #" & Forms!frmReportsSwitchboard!txtEndDate & "#"
End If
Else
'do nothing
End If

Duhh!!!
Thanks,
Jon
 

Users who are viewing this thread

Back
Top Bottom