• Update Syntax (A2K3)

    Author
    Topic
    #454946

    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.

    [indent]


    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


    [/indent]

    dPIFDate is a public variable as date

    What am I doing wrong here?

    Viewing 0 reply threads
    Author
    Replies
    • #1130667

      Literal date values must be enclosed in #s. Try

      mySQL = mySQL & myTable & “.[DateOfFile] = #” & dPIFDate & “#;”

      • #1130670

        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.

    Viewing 0 reply threads
    Reply To: Update Syntax (A2K3)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: