Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If is opened (Access 2000)

    I want to open a report from two different forms belonging to different groups. I want to put the condition in the report, that if the report is opened ffrom form1, to have one record source and if from form2, to have another record source.How could i do it ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: If is opened (Access 2000)

    If the report will bebased on the same table or query but with different criteria, you can specify the criteria in the WhereCondition argument of DoCmd.OpenReport. This is the easiest way, since you specufy the criteria in the code behind the form.

    If the report has to be based on entirely different tables or queries, you can set the record source in theOn Open event of the report:

    Private Sub Report_Open(Cancel As Integer)
    If CurrentProject.AllForms("frmFirst").IsLoaded Then
    Me.RecordSource = "tblFirst"
    ElseIf CurrentProject.AllForms("frmSecond").IsLoaded Then
    Me.RecordSource = "qrySecond"
    End If
    End Sub

    If neither form is open, the report will use the record source specified in design view.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If is opened (Access 2000)

    Just to say that all worked excellent with me ! Thank you !!!!

Posting Permissions

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