Results 1 to 4 of 4
  1. #1
    Pianopizza5 is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2019
    Posts
    46

    VBA error handling - clear field

    I have some fields in my database that have input masks. If a user enters something that doesn’t follow the mask, they get an error. Using error handling in VBA, I created a message box. But I also want to clear the field to make it easier for the user to reenter an item and/or leave the field (which will also prevent the form from crashing). For the short text, I cleared it using txtPhoneNumber = “”.



    However, I haven’t had any luck with the Date and Number format.

    I tried txtDate = #1/1/1900# and got the “The macro or function set to BeforeUpdate…” error (I don’t have a BeforeUpdate event); and the DoCmd.RunCommand Undo.

    Does anyone have any ideas/or suggestions on how I can clear a field on error?

    Thanks!

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2021
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Have you tried: Me.[NameOfControl].Undo
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Pianopizza5 is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2019
    Posts
    46
    Thank you so much! That worked. I really appreciate it.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2021
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by Pianopizza5 View Post
    Thank you so much! That worked. I really appreciate it.
    You're welcome. Always pleased to help if I can
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Replies: 6
    Last Post: 11-14-2021, 10:44 AM
  2. Register Form w/ Error Handling VBA Code
    By jrosen12 in forum Forms
    Replies: 1
    Last Post: 12-22-2014, 04:24 AM
  3. VBA Error Handling
    By jimmyac23 in forum Access
    Replies: 3
    Last Post: 09-22-2014, 11:27 AM
  4. Replies: 3
    Last Post: 09-05-2012, 10:23 AM
  5. VBA Error Handling Clear
    By josephff in forum Programming
    Replies: 19
    Last Post: 08-30-2011, 12:12 PM

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
  •  
Other Forums: Microsoft Office Forums