Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Update Syntax (A2K3)

    Another no brainer, but I can't see it for the life of me.

    I want to update a field in a table with a date. I'm using the following code to run the update but the date is always 12/30/1899 unless I hard code the date in.

    <hr>Function UpdateIt(myTable As String)
    Dim mySQL As String

    dPIFDate = Date

    mySQL = "UPDATE " & myTable & " SET "
    mySQL = mySQL & myTable & ".[DateOfFile] = " & dPIFDate & ";"


    DoCmd.SetWarnings False
    DoCmd.RunSQL mySQL
    DoCmd.SetWarnings True
    End Function<hr>

    dPIFDate is a public variable as date

    What am I doing wrong here?
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

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

    Re: Update Syntax (A2K3)

    Literal date values must be enclosed in #s. Try

    mySQL = mySQL & myTable & ".[DateOfFile] = #" & dPIFDate & "#;"

  3. #3
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update Syntax (A2K3)

    Thanks Hans, that's what was missing. I knew to put the pound sign in, but was putting the last one in in the wrong place.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

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