Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2007
    Posts
    72

    Unanswered: extra ) in query expression

    Code:
    "DELETE * FROM loans WHERE (bookid=" & Me.bookid & ")"
    This gives runtime error 3075. extra ) in query expression.

    bookid is a number field and Me.bookid is a textbox on a form.

    I've tried
    Code:
    "DELETE * FROM loans WHERE (bookid='" & Me.bookid & "')"
    which gives datatype mismatch in criteria expression.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    just a dumb question what is the text in bookid
    is it possible its string and has a ) lurking in it?
    IIRC you don't actually need to bracket everything (unless you are doing joins) so I'd try
    "DELETE * FROM loans WHERE bookid=" & Me.bookid
    ..for a numeric bookid
    and
    "DELETE * FROM loans WHERE bookid=" & chr$(34) & Me.bookid & chr$(34)
    ...for a string bookid
    I'd want to check that the value in bookid is what I'm expecting.. it may require me.bookid.text or me.bookid.value

    I may want to examin the bookid if it was alphanumeric and REPLACE any " with the relevant escape sequence (IIRC thats \")
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jul 2007
    Posts
    72
    I just realised what's happening! After going through all the things you suggested which confirmed that it's definitely a number field.
    The form is a continuous subform, you type the bookid number in the field and press enter or tab and the title shows in the field - but the cursor goes to a new half-empty record (half-empty because the personid of the main form is the default value of person id on the subform) and THIS is the record it is trying to delete!

    How can I stop the cursor from going to a new record, until it the user actually clicks in the next empty bookid field?

    I moved the personid field to the right of the title field and this seems to keep the cursor on that record most of the time but if a random click happens the error message pops up. Would making it a single form and not continuous stop this?
    Last edited by bronisaurus; 01-26-09 at 12:44.

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Why not just change the code to detect the new record:

    If Not Me.NewRecord Then
    ... what you have now
    End If
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Jul 2007
    Posts
    72
    Belated thanks for that. I didn't want to speak too soon but it's all working well (apart from my other query display problem, but that's something I'll come back to later).

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Glad to help
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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