Two Reports From One Form

C

Cillies

Hi All!

Is it possible to have two reports and be fit to call them from the on
form.

I have created two reports, 1 with detailed info and 2 with jus
totals. (but the latter is not linked up to the form used for callin
up the first report.)

The thing is, on my form I can select data by employee and by al
employee. which will return info on an individual level and info on al
employees

But now I want to select All employees and return a different Report
one with the totals. The one mentioned above 2

I don't know if I can do this! but below I have pasted the VB code t
give you a better understanding of what I am talking about.

I.e. I want to select by individual and get report1 and also I want t
select All and retrieve a different report.(2)


VB CODE
Option Compare Database
Option Explicit

Private Sub BeginDate_AfterUpdate()
Me!EndDate = Me!BeginDate
Me!EndDate.SetFocus
End Sub


Private Sub cboEmployeeName_AfterUpdate()
If Me!cboEmployeeName = "*" Then
Me!chkAllEmployee = True
Else
Me!chkAllEmployee = False
End If
End Sub


Private Sub chkAllEmployee_AfterUpdate()
If Me!chkAllEmployee Then
Me!cboEmployeeName = "*"
Else
Me!cboEmployeeName = Null
Me!cboEmployeeName.SetFocus
End If
End Sub

Private Sub chkAllDates_AfterUpdate()
If Me!chkAllDates Then
Me!BeginDate = DMin("DateWorked", "[Time Card Hours]")
Me!EndDate = DMax("DateWorked", "[Time Card Hours]")
Else
Me!BeginDate = Null
Me!EndDate = Null
Me!BeginDate.SetFocus
End If
End Sub

Private Sub cmdPreview_Click()
DoCmd.OpenReport "IMMREPORTALL", acViewPreview
End Sub

Private Sub Form_Activate()
DoCmd.Restore
End Sub

Private Sub Form_Load()
Me!BeginDate = DMin("DateWorked", "[Time Card Hours]")
Me!EndDate = DMax("DateWorked", "[Time Card Hours]")
End Sub
Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click


DoCmd.Close

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click

End Sub



I hope some one can help
Kindest Regard
 
M

Marshall Barton

You didn't post the report's record source queries, but it
appears that the queries have some complex criteria
expressions that refer to the text boxes on the form.

I suggest that you discard the criteria in the query and use
the OpenReport method's WhereCondition argument instead:

Private Sub cmdPreview_Click()
Dim strWhere As String
If Me!chkAllEmployee = False Then
strWhere = strWhere & " And EmployeeName =""" _
& cboEmployeeName & """"
End If
If Not IsNull(Me!BeginDate) Then
strWhere = strWhere & " And DateWorked Between #" _
& Me!BeginDate & "# And #" & Me!EndDate & "#"
End If
strWhere = Mid(strWhere, 6)
DoCmd.OpenReport "IMMREPORTALL", acViewPreview, , _
strWhere
DoCmd.OpenReport "otherreport", acViewPreview, , strWhere
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top