Results 1 to 8 of 8

Handle Errors From Button Wizard Buttons

  1. #1
    MaxQTime is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Location
    Kelowna, B.C.
    Posts
    29

    Handle Errors From Button Wizard Buttons


    HI Everyone, I've been building a database and I've been using the button wizard to make things go a bit quicker. It's a customer database and I have a form with a search box and list box to allow the user to search for a customer. There is a "edit customer info" button that I used the wizard to create that opens a new form with all the selected customer info. The button kicks an error if there is no customer selected in the list box. My question is;

    How can I handle that error, ultimately I would like to pop up a message box that asks the user to select a customer. I can't however find the actual VBA code that was generated from the wizard.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    19,996
    The wizard probably created an embedded macro. My guess is this would be the equivalent VBA code:

    http://www.baldyweb.com/wherecondition.htm

    to your question, you'd add a test to make sure a selection was made first.
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  3. #3
    MaxQTime is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Location
    Kelowna, B.C.
    Posts
    29
    I guess i could remake the buttons using this code and add in a "If me.controlname != null" to catch the error.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    19,996
    That's what I would do, though the test would be more like:

    If Len(Me.SomeControl & vbNullString) = 0 Then
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  5. #5
    MaxQTime is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Location
    Kelowna, B.C.
    Posts
    29
    Thank you. This is working really well. I always love learning some VBA code.

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    5,756
    Quote Originally Posted by MaxQTime View Post
    I always love learning some VBA code.
    Then if you don't know about the Nz function, this should add to your repertoire and list of things to research (it's the method I've adopted)

    If Nz(Me.SomeControl,"") = "" Then

    and it's usually shorter. After all, there are only so many words you can type in a lifetime, and I don't want to ever hit my limit before I'm gone.
    - "doesn't work" is no help. Post err msgs and where.
    - Use code tags for code/sql. Implement changes in copies of your database.
    Sometimes I talk to myself - like when I need expert advice.

  7. #7
    MaxQTime is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Location
    Kelowna, B.C.
    Posts
    29
    Thank you, I"m going to have to keep this in mind. This makes sense for testing for null value for checking.

  8. #8
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    5,756
    They are both doing pretty much the same thing, just in different ways.
    In one, if Null add an empty string (zls) to the end and test its length. In the other, convert Null to "" and compare.
    Null becomes ""
    "" remains ""
    Any other input is not ""
    Thus the input is either "" or it is not.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Button wizard doesn't work.
    By Ed Mattison in forum Forms
    Replies: 8
    Last Post: 09-07-2016, 07:25 AM
  2. Replies: 6
    Last Post: 04-02-2014, 11:17 AM
  3. Error on command button wizard
    By jcor in forum Forms
    Replies: 7
    Last Post: 05-10-2013, 09:34 AM
  4. Command Button Wizard and Matching Fields
    By tylerg11 in forum Forms
    Replies: 5
    Last Post: 10-07-2011, 01:07 PM
  5. Command Button Wizard
    By cscobba in forum Forms
    Replies: 7
    Last Post: 01-26-2011, 04:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums