Results 1 to 4 of 4
  1. #1
    ssalem is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Posts
    39

    Reopen Form after No data is found for report

    Not sure how to handle this and just need to be pointed in the right direction. Can't seem to find what I am looking for by doing research. My task I think should be rather simple and something I am sure someone has incountered before but can't seem to find it. I have a report whose parameters are controlled by a form. Right now I have the report checking on the No Data event if no records are returned to show a message box and set Cancel = True so the report does not open. But on the On Close event of the report it closes the Form. I want the form to either remain open or reopen after no data is found. I have tried running a macro that reopens the report and is triggered in the no data event but of course it does not work because when the report closes it closes the form. But if it is a good report i need it to close the form when the report is closed. Do I need to instead of using the No Data Event be checking the Data Set in the Report Open event instead and then cancel opening the report and set my form to visible. I just need some direction and can figure out the commands.

    Thanks in advance.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    Should be able to have conditional code in the Close event to not close the form if there is data. Try in the Close event:

    If Me.HasData Then
    DoCmd.CloseForm ...
    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.

  3. #3
    ssalem is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Posts
    39
    Hi I figured it out. It was at all not what I thought though. Putting a conditional on the close of the form did not solve the problem. It still returned to the switchboard which closed everything. What I ended up doing is creating a Public variable as boolean in my standard module. I set it to False and only set it to True if the where no records in the dataset. I created a do until varialbe was false loop in the switchboard to re-open the report, thus reopening the form for the parameters. This way if a person kept putting invalid report parameters the program would return to the form giving them a chance to put valid parameters in. Only when they did put in valid parameters or hit the quit button would it exit the form. The whole trick was handling it at the switchboard level. I only figured this out by totally stepping through the whole vb I had written. Thought I would post this in case someone else needed quidance in handling this same problem.

  4. #4
    ssalem is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Posts
    39
    Just another quick note...on my Quit button command I had to set my Public variable to False to be able to quit.

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

Similar Threads

  1. Replies: 3
    Last Post: 01-31-2013, 07:20 PM
  2. Replies: 4
    Last Post: 01-04-2013, 04:03 PM
  3. Method or data member not found
    By papa yaw in forum Programming
    Replies: 5
    Last Post: 12-17-2012, 02:19 PM
  4. If no matches Reopen form after Msgbox
    By LoveLearning in forum Access
    Replies: 2
    Last Post: 07-18-2012, 06:08 PM
  5. Replies: 9
    Last Post: 03-29-2011, 07:08 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