Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2014

    Question Unanswered: Numeric Variable Syntax - HELP!

    I am going crazy here. I defined a varialbe as long, as it is an autonumber field. I then identify the dmin value of the field based on my property number. That works. I then want to delete that record but am getting a syntax error 3075 missing operator. What operator? It is numeric.

    ? DMin("KEY_NUM", "CUSTODY", "PROPERTY_NUMBER = '" & myproperty & "'")

    ? mykey

    Error thrown:

    mykey = DMin("KEY_NUM", "CUSTODY", "PROPERTY_NUMBER = '" & myproperty & "'")
    DoCmd.RunSQL ("DELETE * FROM CUSTODY WHERE [KEY_NUM] = & mykey & ")

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    DoCmd.RunSQL ("DELETE * FROM CUSTODY WHERE [KEY_NUM] = " & mykey)
    the problem is that you have to drop out of string mode to add a variable/control.

    I strongly recommend that you always assign the value of your sql to a variable (at least whilst developing the app, this makes it far easier to see what your SQL is.

    strSQL = "DELETE * FROM CUSTODY WHERE [KEY_NUM] = " & mykey
    DoCmd.RunSQL strSQL can either write it to the debug window, display it in a messagebox or immediate window

    just because the code compiles doens't mean you are forming valid SQL
    I'd rather be riding on the Tiger 800 or the Norton

Tags for this Thread

Posting Permissions

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