Results 1 to 4 of 4
  1. #1
    Daryl2106 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    167

    Unmatched record and msgbox

    Hi,

    I was wondering how you write the vba for msgbox to say "No records match the Student ID entered" when a query is opened from a form button. That is if the query can't find a record to match the data in an unbound text box.Thanks in advance.



    Take care,

    Daryl

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    I presume you mean an Access query object. Why open a query object?

    If you open a query object then have to do a search of the query with domain aggregate function (such as DLookup or DCount). Why not just do a search of the table with code in the button event?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Daryl2106 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    167
    The code associated with the button is simply Me.Requery. If there is no mtch for the ID in the query criteria (as entered on a forum) then no records are returned. I need to let the user know that they have entered and invalide ID.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    So you are not opening a query, just filtering a form?

    Why not help the user make a valid selection? This can be managed with a LimitToList combobox or a listbox.

    Don't let the requery take place if there is not a valid entry. The code can do a lookup on data.

    If IsNull(DLookup("ID", "tablename", "ID=" & Me.ID)) Then
    MsgBox "Invalid ID. Try again."
    Me.tbxID.SetFocus
    Else
    Me.Requery
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Remove Only Part of Record Using Unmatched Query
    By garrettgivre in forum Access
    Replies: 8
    Last Post: 08-13-2013, 03:15 PM
  2. Help? One Table, Finding Unmatched
    By geofftke in forum Access
    Replies: 1
    Last Post: 06-07-2013, 11:20 PM
  3. Unmatched Addresses Query
    By #1Newbie in forum Queries
    Replies: 3
    Last Post: 06-03-2013, 06:54 AM
  4. Match and then unmatched
    By dakpluto in forum Queries
    Replies: 9
    Last Post: 04-22-2013, 12:51 PM
  5. Replies: 1
    Last Post: 12-08-2011, 01:52 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