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

    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 & "'")
    1036832

    ? mykey
    1036832

    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
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Code:
    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.

    Code:
    strSQL = "DELETE * FROM CUSTODY WHERE [KEY_NUM] = " & mykey
    DoCmd.RunSQL strSQL
    ..you 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
  •