Results 1 to 3 of 3
  1. #1
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694

    using FindFirst with a Date Criteria (syntax error)


    all,

    I am getting a syntax error on the findfirst line here:
    Code:
    dim sDate as Date
    sDate = "5/5/2005"
    
    'OPEN TABLE
    rs.MoveLast
    rs.MoveFirst
    i = 0
    
          'LOCATE STARTING POINT
          rs.FindFirst "[orderdate] => " & sDate
    I'm not fond of using dates in anything. I have no idea how to get rid of the error. The syntax error is missing operator. The formats for the date variable I've tried are:

    #5/5/2005#

    I have also tried variations of the findfirst line:

    rs.FindFirst "[orderdate] => #" & sDate & "#" (when variable is in quotes)
    rs.FindFirst "[orderdate] => #5/5/2005#"

    I have not tried the findfirst line with (). Can I get suggestion here as to what to try next? I have tried the importing routine to check for corruption. That did not correct the problem. thanks!

    (I think access might be evaluating the data variable "/" signs as arithmetic operators. that would make sense with the warning messages. that doesn't shed any more light for me though!).

  2. #2
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    VBA is always fickle with dates.

    If you have a numerical field in your table, can you test your code with that? If it works, then you'll know it's the date that is giving you the grief.

    Cheers,

  3. #3
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    it wasn't, it was da** OPERATOR. it doesn't accept =>. But it does accept >=. what are the chances? i'm sure it was my fault again.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. SQL INSERT INTO Date Syntax Error
    By tuna in forum Programming
    Replies: 5
    Last Post: 08-10-2010, 06:17 AM
  2. RST Findfirst date problem
    By ColPat in forum Programming
    Replies: 3
    Last Post: 08-09-2010, 07:28 AM
  3. Syntax error
    By smikkelsen in forum Access
    Replies: 6
    Last Post: 04-28-2010, 09:38 AM
  4. Syntax Error
    By KLynch0803 in forum Programming
    Replies: 11
    Last Post: 02-04-2010, 01:45 AM
  5. sql syntax error
    By SMAlvarez in forum Access
    Replies: 1
    Last Post: 03-12-2009, 09:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums