Re: Syntax error

Tech-Archive recommends: Fix windows errors by optimizing your registry



Where you have ...

And <=

.... you should have ...

And tblMMD.DateOfMeeting <=

--
Brendan Reynolds (MVP)

"Paul" <Paul@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4FC8E952-05A1-48B6-B9FE-F852FDDAB336@xxxxxxxxxxxxxxxx
>I am running the code below but keep getting syntax error.
>
> "from" and "to" are date fields on my form holding the dates used for the
> criteria
>
> help appreciated
>
> Paul
>
>
> Dim rs As New ADODB.Recordset
> Dim cn As ADODB.Connection
> Dim str As String
>
> Set cn = CurrentProject.Connection
> Set rs = New ADODB.Recordset
>
>
> str = "SELECT tblMMD.mmdID,tblMMD.DateOfMeeting FROM tblMMD WHERE
> (((tblMMD.DateOfMeeting) >= #" + From + "# And <= #" + To + "#))ORDER BY
> tblMMD.DateOfMeeting"
>
> rs.Open str, cn, adOpenStatic, adLockOptimistic
> nMeet = rs.RecordCount
>
> MsgBox nMeet
>
> etc
>
> this does work but does not give the correct record count total:
>
> str = "SELECT tblMMD.mmdID,tblMMD.DateOfMeeting FROM tblMMD WHERE
> (((tblMMD.DateOfMeeting) >= #" + From + "# And (tblMMD.DateOfMeeting) <=
> #" +
> To + "#))ORDER BY tblMMD.DateOfMeeting"
>


.



Relevant Pages

  • Re: Syntax error
    ... "Brendan Reynolds" wrote: ... >> Dim rs As New ADODB.Recordset ... >> Dim str As String ... >> MsgBox nMeet ...
    (microsoft.public.access.modulesdaovba)
  • Syntax error
    ... Paul ... Dim rs As New ADODB.Recordset ... Dim str As String ... MsgBox nMeet ...
    (microsoft.public.access.modulesdaovba)
  • Re: Multi Field SQL Where Clause
    ... The triple quotes cause a syntax error. ... Public sysNtApLkNo as Long ... when using the string as you have defined it the correct values ... Dim sysNtSysCd As String ...
    (microsoft.public.access.forms)
  • Re: Calling a SQL stored procedure
    ... "Syntax error converting datetime from character string." ... How do I pass a datetime value to a datetime parameter. ... > Dim oda As New SqlDataAdapter ... >>I have the following stored procedure in an sql database ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Combo box with Data Validation feature
    ... Private Sub TempCombo_LostFocus ... Dim str As String ... Dim wsList As Worksheet ... Dim cboTemp As OLEObject ...
    (microsoft.public.excel.programming)