Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2009
    Posts
    61

    Unanswered: Opening a Report based on two Criteria from a Form

    Hi,

    I have what should be a simple problem to fix but i cannot find the solution anywhere. I have a form that is used to release a list of production orders. On the form I have two critical peices of criteria that i need to use to open a report with focus. The feild names and data types are as follows:

    DateRlsd - Date/time
    PrimDept - Text

    I am running the report from a query and under each of the columns for the two feilds above I have the following criteria specified:

    [Forms]![frmSchedule_build]![DateRlsd]

    [Forms]![frmSchedule_build]![PrimDept]

    The code that i have to run the report is as follows. The code is set to enter the DateRlsd based on an unbound text box I have where you type the date. It loops through all teh records displayed on the form and then prints the report. The problem is that the report is blank.


    Private Sub cmdAddDate_Click()

    On Error GoTo Err_End

    If IsDate(rlsedate) Then

    DoCmd.GoToRecord , , acFirst

    Me.[DateRlsd] = [rlsedate]

    DoCmd.Save

    Next_Record:

    DoCmd.GoToRecord , , acNext

    Me.[DateRlsd] = [rlsedate]

    DoCmd.Save

    GoTo Next_Record

    Else

    MsgBox "Require a date in the date box"

    End If

    Exit Sub

    Err_End:

    Me.Dirty = False

    DoCmd.OpenReport "rptJournal", acViewNormal

    End Sub

  2. #2
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    Look at "DemoReport2CriteriaA20022003.mdb (attachment, zip).
    Look at Table1, Form1 (VBA), Query1, Report1.
    Open form and try. Adapt it in your mdb.
    Put LIMIT TO LIST = YES (properties on first combo).
    Attached Files Attached Files

  3. #3
    Join Date
    Aug 2009
    Posts
    61
    Thanks for the reply MStef-ZG but unfortunately I don't think this covers what I needs to do. The error checking I have in the code actually works, I just need to open the report displaying all the records that are displayed on my form. Does it have to do with my where condition in the open command?

  4. #4
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    You need to add the fourth argument to the OpenReport command - the where argument. See the help file for more on this.
    10% of magic is knowing something that no-one else does. The rest is misdirection.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •