Results 1 to 4 of 4
  1. #1
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453

    Error checking query and message

    Hi



    have a query

    SELECT tblDeceased.GraveID, tblDeceased.Mlink, tblDeceased.Plot, tblDeceased.GraveNo, tblDeceased.Forenames, tblDeceased.Surname, tblDeceased.Age, tblDeceased.YearOfDeath
    FROM tblDeceased
    WHERE (((tblDeceased.YearOfDeath) Like "*" & [Enter a Year Of Death]));[/CODE]

    this works well but if someone inputs a letter rather than a number nothing comes ups in the related form.

    To make it tidier thought it would be nice if a Message box came up saying - "only numbers are permitted"

    research on the web found me this code snippet

    Code:
    Sub CheckError()
    
    
    On Error GoTo Handler:
    
    Exit Sub
    
    Handler:
    
    MsgBox ("Not a number")
    
    End Sub

    The above code is VBA

    Is it possible to add error checking to a query design? or do I convert the query to VBA, if the latter is there an easy way to convert the query to VBA?

    thanks

    Ian

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    How is YearOfDeath defined in your table? Number or Text?

  3. #3
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Hi

    good point ;-)

    it's defined as text.

    Gets a bit more complicated?

    Ian

  4. #4
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,175
    Hi,

    can't you refer in the query to a field on a form (small dialogue form) and put an input mask on the form field allowing only numbers?

    Kind regards
    Noëlla

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

Similar Threads

  1. Error checking
    By Me.Howard in forum Forms
    Replies: 5
    Last Post: 10-15-2015, 04:06 PM
  2. Error Checking in a text box
    By Paul H in forum Forms
    Replies: 2
    Last Post: 07-23-2015, 01:02 PM
  3. Replies: 14
    Last Post: 03-31-2015, 05:20 PM
  4. Replies: 15
    Last Post: 11-01-2013, 03:24 PM
  5. Error Checking within Form
    By phd4212 in forum Forms
    Replies: 1
    Last Post: 05-09-2012, 02:46 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
  •  
Other Forums: Microsoft Office Forums