Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    sql string problems (2000)

    I getting a data mismatch error on the following code and don't know how to fix it. PalletNumber is a date.

    Dim db As DAO.Database
    Dim smp As DAO.Recordset
    Dim PalletNumber As String

    Set db = CurrentDb
    PalletNumber = "#" & [Forms]![frmNew]![lstPalletNumber].ItemData([Forms]![frmNew]![lstPalletNumber].ListIndex) & "#"
    sqlstr = "SELECT * FROM TBLPALLETS WHERE [DATE] = """ & PalletNumber & """"
    Set smp = db.OpenRecordset(sqlstr)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: sql string problems (2000)

    Since a date is not a string, you shouldn't put quotes around it.

    sqlstr = "SELECT * FROM TBLPALLETS WHERE [DATE] = " & PalletNumber

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: sql string problems (2000)

    Thanks, that did it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •