Access Forms Queries

Posted on 2014-07-14
Last Modified: 2016-06-07
I do not want the second form to query due to no paramaters entered (seems like On Open might help but not sure how to do it).

What I would like is to access the second form from the main page and have the two reports below show zero record (without going throught the query process).  

How the database currently works

Step 1 - From main page "Button One-Components is pressed.
Step 2 - Form "Component Form Page" is opened.
Step 3 - Access automatically runs Query 1 and Query 2 as a means to populate Report 1 and Report 2 even though there are no parameters (wastes time).

Can you help?

Main Form

Button one - Components
                                                                                                                             Submit Button

Second Form "Component Form Page"

Input One
Input Two

                            Report 1  Query 1

                            Report 2  Query 2
Question by:gazdzid
    LVL 30

    Expert Comment

    Upload a sample database and direct us what to do to experience the problem.
    LVL 84

    Accepted Solution

    Why does "Access automatically runs Query 1 and Query 2"? The only time Access will "automatically" do something is if you've told it to, or if you've bound an object (like a Form or Report) to that query. If you only want the second form to open your reports AFTER the two parameters are entered, then check for those values before you run code that opens the report:

    If Nz(me.ParameterOne, "") = "" Then
      Msgbox "You must enter Parameter One"
      Exit Sub
    End If

    If Nz(me.ParameterTwo, "") = "" Then
      Msgbox "You must enter Parameter Two"
      Exit Sub
    End If

    DoCmd.OpenReport "YourReport" etc etc

    Obviously you'd have to change that to match field and Report names in your project.

    Note that if you're using 2010 or higher, and you've Embedded those reports on the Form, then Access will always try to run them. The only way around that would be to remove the SourceObject value from those embedded SubReport objects, and set them only when your parameters tests above are completed.
    LVL 75

    Expert Comment

    by:Anthony Perkins
    Topics: Microsoft Access Database ,MS SQL Server
    Does this question have anything to do with MS SQL Server?
    LVL 26

    Expert Comment

    No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

    I have recommended this question be closed as follows:

    Accept: Scott McDaniel (Microsoft Access MVP - EE MVE ) (http:#a40196535)

    If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

    Experts-Exchange Cleanup Volunteer

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now