Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    input box (Access 2000)

    strCustomerID = InputBox("Please enter Customer number ")
    Me.RecordsetClone.FindFirst "CustomerID = " & strCustomerID
    If Me.RecordsetClone.NoMatch Then
    MsgBox "CustomerID " & strCustomerID & " Not Found!!"
    Me.Bookmark = strBookmark
    Exit Sub
    Else
    Me.Bookmark = Me.RecordsetClone.Bookmark
    End If





    I have a small code that asks for the Customer number through an input box. When i click the event,
    a dialog box appears with the words "Please enter Customer Number). Than the input box contains the options Ok and Cancel.
    If i click OK then the code wroks, but when i click cancel i receive the message "Syntax error, missing operator"
    runtime error 3007.I want instead to close exit the sub but i do not know how.For a greater clarityu here is my code:
    strCustomerID = InputBox("Please enter Customer number ")
    Me.RecordsetClone.FindFirst "CustomerID = " & strCustomerID
    If Me.RecordsetClone.NoMatch Then
    MsgBox "CustomerID " & strCustomerID & " Not Found!!"
    Me.Bookmark = strBookmark
    Exit Sub
    Else
    Me.Bookmark = Me.RecordsetClone.Bookmark
    End If

    I would like to imrove the cancel event of the dialog in the input box .Maybe it is possible ?

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

    Re: input box (Access 2000)

    If the user clicks Cancel in the input box, the InputBox function returns an empty string. So you can check for that:

    strCustomerID = InputBox("Please enter Customer number ")
    If strCustomerID = "" Then Exit Sub
    Me.RecordsetClone ... ' continue with the rest of your code

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: input box (Access 2000)

    In addition to Hans's suggestion, it isn't necessary to set a bookmark if NoMatch is true. You only need to set the bookmark if a match is found. Otherwise, the bookmark doesn't change.
    Charlotte

Posting Permissions

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