Results 1 to 6 of 6
  1. #1
    Jojojo is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    46

    Report data doesn't populate from Query, just opens query

    Hi,

    I have a Member Type Report set up. The Report opens MemberTypeForm - where the user selects that type of member they want as criteria via combo box. When the user clicks OK, the form opens the MemberType Query instead of populating that data into the Report.

    This is the code I have in the Form's Event "OnClick"
    Private Sub OK_Click()
    Me.Visible = False
    DoCmd.OpenQuery "MemberType Query", acViewNormal, acEdit
    DoCmd.Close acForm, "MemberTypeForm"


    End Sub

    I know it's coded to open the Query when clicked, and I'm assuming it has to be in order for the query to Run, but then how do I get that query to run where the user can't see it, and have the data it produces show up in the report that the Member Type Report.

    Thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You open the report, not the query (DoCmd.OpenReport). The report will run the query in the background on its own.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    As long as the query exists, opening the Report it is attached to will run the query. It need not be opened for this to happen. Just open the report and you should be set, assuming your query is properly written to take whatever you need from the form.

  4. #4
    Jojojo is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    46
    Quote Originally Posted by pbaldy View Post
    You open the report, not the query (DoCmd.OpenReport). The report will run the query in the background on its own.
    Thanks! The OpenQuery vs OpenReport was the problem - but now I get a Runtime Error 2585 when I click ok.

    This is the code I have in the report events - is the problem in here?:

    Private Sub Report_Close()
    DoCmd.Close acForm, "MemberTypeForm"
    End Sub
    Private Sub Report_Open(Cancel As Integer)
    ' Set public variable to true to indicate that the report
    ' is in the Open Event
    bInReportOpenEvent = True

    ' Open MemberTypeForm
    DoCmd.OpenForm "MemberTypeForm", , , , , acDialog

    ' Cancel Report if User Clicked the Cancel Button
    If IsLoaded("MemberTypeForm") = False Then Cancel = True

    ' Set public variable to false to indicate that the
    ' Open event is completed
    bInReportOpenEvent = False
    End Sub

  5. #5
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Don't open the form from the report. Open the report from the form.

  6. #6
    Jojojo is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    46
    Thank you!
    Last edited by Jojojo; 10-06-2011 at 06:20 PM. Reason: solved

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

Similar Threads

  1. Replies: 1
    Last Post: 10-24-2011, 04:11 PM
  2. Simple query doesn't return anything
    By lbytesxk in forum Queries
    Replies: 6
    Last Post: 09-15-2011, 06:50 AM
  3. Query doesn't work the day after
    By sithis876 in forum Queries
    Replies: 1
    Last Post: 07-13-2010, 07:11 AM
  4. Query doesn't return all data
    By hawzmolly in forum Queries
    Replies: 6
    Last Post: 03-26-2010, 09:12 AM
  5. Form doesn´t update with Query.
    By disturbedgod in forum Forms
    Replies: 10
    Last Post: 02-09-2010, 02:00 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