Results 1 to 7 of 7
  1. #1
    Nixx1401 is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Feb 2010
    Location
    Barbados
    Posts
    115

    Parameter Queries & Reports

    I created a report using a parameter query. When the parameters are entered the report generates correctly and fine.



    The parameters are enter ID# and enter name because more than one individual has the same name.

    but when the name and ID# entered is not in the database the report displays with no info

    I would like that if the parameters entered does not correspond to the info in the database for it to tell the user this and ask them to enter the information again

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    what have you tried?

  3. #3
    Nixx1401 is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Feb 2010
    Location
    Barbados
    Posts
    115
    I created a query and entered the following parameters [Please enter name (first then last)] and [Please enter ID#] this displays the the correct information once the parameters enters corresponds to info in the database if that data entered does correspond to data in the database the report is blank

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    there is no option to check criteria in a parameter query. However, you can add code behind the report's OPEN or LOAD event to close itsself and re-open it. That's the way I have done it in the past.

    not elegant, but it works.

  5. #5
    Nixx1401 is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Feb 2010
    Location
    Barbados
    Posts
    115
    I am not too code savvy can you post the necessary code please

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    something like:
    Code:
    if me.recordsetclone.recordcount = 0 then
       docmd.close
          msgbox "The params entered result in no data. Reenter"
             docmd.openreport me.name
    end if

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    This is why I don't use parameter queries. I build forms for user to enter criteria then code behind the form opens report only if criteria is valid. Use combo and list boxes to control user input. More user friendly, less frustration. I use the WHERE argument of DoCmd.OpenReport to pass the filter criteria to report. Be aware, the more user friendly the more code.

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

Similar Threads

  1. parameter queries
    By cpride in forum Access
    Replies: 1
    Last Post: 03-23-2011, 09:21 PM
  2. Problem with Access Queries\Reports
    By Crysis3nt in forum Access
    Replies: 1
    Last Post: 09-09-2010, 02:26 AM
  3. Queries, Forms, Reports..
    By groundhog in forum Access
    Replies: 3
    Last Post: 07-07-2010, 12:30 PM
  4. Running parameter queries from VBA
    By John Southern in forum Programming
    Replies: 6
    Last Post: 03-25-2010, 10:24 AM
  5. Reports based on queries
    By Merkava in forum Reports
    Replies: 13
    Last Post: 12-14-2009, 11:21 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