Results 1 to 6 of 6
  1. #1
    cowman is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2013
    Posts
    3

    Query fails to find matching records

    Been round the block a few times. Trained on COBOL and FORTRAN IV back in early 70's but find ACCESS really frustrating- maybe an age thing!


    Anyway- help please!!
    I have a client file that will need editing. The user is presented with a form holding a text box to enter the paramater (Client Ref) for a query.
    The results are displayed in another form based on that query. Works great if matches are found. If not, it displays a blank/new record. I want to either 1) stop this or 2) tell the user that their query was unsuccessful.

    Thanks

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Recommendation:

    Don't use spaces or special characters in your field or object names. Leads to many syntax errors and frustration.
    Readers really need to see your tables and relationships (a jpg) to understand your set up.

    You could offer a combobox with a ClientName so user could select a particular record.

    Perhaps you could tell us the intent of the form --is the user suppose to find a client.
    If you allow typing into a box, there's all sorts of typos/spellings possible/

  3. #3
    cowman is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2013
    Posts
    3
    The activity is to locate a client record for editing.
    The Client file has over 700 records so I am offering the choice of entering the surname (lots of typo errors possible) or use the start of surname and wild card eg Jo* and they then locate correct record in results fron query. Do not want them to use this facility to CREATE a NEW Client record.
    The parameter query is working fine and a form shows the matching records, it's reacting to a situation where no records are found, that is my problem.
    THanks

  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
    Try a DCount() on the query, testing for >0 before opening the second form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    cowman is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2013
    Posts
    3
    THanks. I can see what you mean- test the result of the query before opening the 'results' form. Sorry to be a pain, but just how/where to I put the DCount(). Presumably it has to check after the query has been executed but before the form open.
    My command button on the 'parameters' form is set to Open the Form which is based on the query. This seems to execute the query upon which the form is based and immediately display the results.
    Should this be in 3 steps- execute the query, test the outcome, display the form depending on the results from DCount().
    An example would be really helpful.
    Thanks again.

  6. #6
    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'm on an iPad, so no Access, but along the lines of:

    Code:
    If DCount(...) > 0 Then
      'open the form
    Else
      'give the user a message box
    End If
    with the DCount arguments filled in of course.
    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. Find matching data between 2 queries
    By michael.p.ryan1 in forum Access
    Replies: 3
    Last Post: 08-24-2012, 05:51 PM
  2. Query to exclude non matching records
    By L1882 in forum Queries
    Replies: 1
    Last Post: 04-03-2012, 08:44 AM
  3. Replies: 1
    Last Post: 10-24-2011, 08:01 AM
  4. Replies: 1
    Last Post: 08-11-2011, 11:33 AM
  5. Replies: 6
    Last Post: 02-10-2011, 07:09 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