Results 1 to 2 of 2
  1. #1
    kilosierra71 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    6

    Need some help with a No Records Found query

    I've got a Form/Query set up where the user clicks a button and enters search criteria - in this case its a Phone Number - to confirm if the record already exists.



    If the record exists, the user is done and they move on - end of story.

    However, if no records are found with the Phone Number query I'd like for the user to be prompted with a pop up box or button or something asking them if they'd like to create a new entry.

    Currently, the way new customer info gets entered into the database is with a bound form (for the sake of this post lets call it the 'New Customer' form). Ideally, this form works fine and people are comfortable using it so I'm not looking to change or alter the New Customer form or its processes.

    I would like a way for this New Customer form to be prompted ("No Phone Number found, would you like to create a new entry?") when a Phone Number query returns no records.

    I'm not an Access whiz so simple is better. Thanks and apologies for the extendo post!

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    I would do something to the effect of:

    'This goes in whatever event you have once the user enters the phone number

    Code:
    If DCount("PhoneNum", "tblCustomers", "PhoneNum = " & Me.phoneControlName) > 0 Then
    MsgBox "This phone number exists. Press OK to continue." , vbOkOnly
    Exit Sub
    Else
    If (MsgBox "This phone number does not exist. Enter new customer?", vbYesNo) = VbYes Then
    DoCmd.OpenForm "New Customer"
    Else
    Exit Sub
    End If
    End If
    You should be able to follow long with what's happening there. DCount just counts up how many instances of the phone number there are.

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

Similar Threads

  1. MsgBox for no records found
    By Lxmanager in forum Forms
    Replies: 4
    Last Post: 11-02-2010, 12:31 PM
  2. Query not found, but it is there
    By Gdm in forum Queries
    Replies: 5
    Last Post: 05-21-2010, 05:59 AM
  3. Replies: 1
    Last Post: 04-29-2010, 05:22 PM
  4. Number of Records Found by a Query?
    By Xiaoding in forum Queries
    Replies: 3
    Last Post: 03-05-2010, 03:34 PM
  5. Return 0 if no records found
    By skwilliamson in forum Programming
    Replies: 1
    Last Post: 12-01-2009, 10:54 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