Results 1 to 4 of 4
  1. #1
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93

    VBA for a field displaying #Error

    Hi,
    I have a field that calculates times in 24hr format on a form, and occasionally users will enter the wrong time in and the calculation will display "#Erorr" but they wont notice and they will continue on. The fields name is "ElapsedTime".
    So, I would like to create a popup box in VBA that would basically tell them tocheck their times for incorrect entries.


    I have created what I think is a If statement, but it wont popup a box. I put it in the object AfterUpdate property and the On Dirty property.
    Here is the code:
    Code:
    Private Sub ElapsedTime_AfterUpdate()
    If Me.ElapsedTime = "#Error" Then
    MsgBox "Please double check your time entries" _
            & vbCrLf & "and try again.", vbCritical, _
        "There is an incorrect time entry!."
         
    End If
        
    End Sub
    Can anyone offer any tips on what I could be doing wrong?
    Thanks in advance. FunkyG

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I would not expect it to return that. You can try IsError(), but I'd probably check with

    If Not IsDate(...) Then

    Also, typically validation is done in the before update event, which can be cancelled.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    Hi,
    I checked out the IsError() but I dont quite get the syntax. Also, I dont think the IsDate() would work either since the value is not a date. Can you elaborate a little more on the IsError function?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    IsDate works on time values as well. I'm not sure I've ever used IsError, so if you want to go that way check it out in VBA help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Displaying a Field Value From Another Form
    By Lupson2011 in forum Forms
    Replies: 5
    Last Post: 08-31-2011, 08:19 AM
  2. Displaying image in calculated field
    By ceci123 in forum Access
    Replies: 2
    Last Post: 01-25-2011, 11:51 AM
  3. Displaying all the entries in one field
    By canfish in forum Reports
    Replies: 5
    Last Post: 07-29-2010, 02:19 PM
  4. Error when displaying reports
    By Steve T in forum Reports
    Replies: 1
    Last Post: 07-22-2010, 07:20 AM
  5. Error displaying image on form
    By mamba716 in forum Forms
    Replies: 6
    Last Post: 06-17-2009, 09:13 AM

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