p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

access thread: Printing 2 Reports from 1 Command Button


Message #1 by Alex Mather <AMather@c...> on Fri, 15 Jun 2001 15:59:29 -0400
Hi. I am not very experienced with VBA so I need some help. I have a few

reports thats results depend on the values in some fields in my form.

 

There are 3 fields as of now that can contain values.

 

A start date field, an end date field, and a team field. (The team field

being a combo box)

 

If the user leaves the combo box empty I would like to run a report for all

of the teams. If they select a particular team I would like to run a

different report.

 

Here is my code: (From the command button)

 

Private Sub preview_report_button_Click()

On Error GoTo Err_preview_report_button_Click

 

    Dim stDocName As String

    

    If [Forms]![Form for Cash Trans]![supelist].Value = "" Then

    stDocName = "Report Detail for Entire Dept"

    Else

    stDocName = "Report Detail for Team"

    End If

    

    DoCmd.OpenReport stDocName, acPreview

    

Exit_preview_report_button_Click:

    Exit Sub

 

Err_preview_report_button_Click:

    MsgBox Err.Description

    Resume Exit_preview_report_button_Click

    

End Sub

 

If the user selects a team the report runs fine. If the user does not I get

an error. It says I have a problem in the code for my detail section of the

report. It says: "Run Time Error '2427' You entered an expression that

contains no value." Then the debugger comes up. And the following code is

highlighted:

 

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

 

If (Me![amt].Value >= 50) Then *************This line is highlighted.

             Me![amt].FontWeight = 700

Else

             Me![amt].FontWeight = 400

End If

 

If (Me![otid].Value = 0) Then

             Me![otid].Visible = 0

Else

             Me![otid].Visible = -1

End If

 

End Sub

 

Can anyone help me???

 

Thanks in advance.

Alex Mather

Intranet Dev

Message #2 by Alex Mather <AMather@c...> on Fri, 15 Jun 2001 16:39:28 -0400
I have figured this out on my own.



I had the syntax wrong. The correct syntax is:



IsNull(Me![supelist])



Sorry.



-----Original Message-----

From: Alex Mather [mailto:AMather@c...]

Sent: Friday, June 15, 2001 3:59 PM

To: Access

Subject: [access] Printing 2 Reports from 1 Command Button





Hi. I am not very experienced with VBA so I need some help. I have a few

reports thats results depend on the values in some fields in my form.

 

There are 3 fields as of now that can contain values.

 

A start date field, an end date field, and a team field. (The team field

being a combo box)

 

If the user leaves the combo box empty I would like to run a report for all

of the teams. If they select a particular team I would like to run a

different report.

 

Here is my code: (From the command button)

 

Private Sub preview_report_button_Click()

On Error GoTo Err_preview_report_button_Click

 

    Dim stDocName As String

    

    If [Forms]![Form for Cash Trans]![supelist].Value = "" Then

    stDocName = "Report Detail for Entire Dept"

    Else

    stDocName = "Report Detail for Team"

    End If

    

    DoCmd.OpenReport stDocName, acPreview

    

Exit_preview_report_button_Click:

    Exit Sub

 

Err_preview_report_button_Click:

    MsgBox Err.Description

    Resume Exit_preview_report_button_Click

    

End Sub

 

If the user selects a team the report runs fine. If the user does not I get

an error. It says I have a problem in the code for my detail section of the

report. It says: "Run Time Error '2427' You entered an expression that

contains no value." Then the debugger comes up. And the following code is

highlighted:

 

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

 

If (Me![amt].Value >= 50) Then *************This line is highlighted.

             Me![amt].FontWeight = 700

Else

             Me![amt].FontWeight = 400

End If

 

If (Me![otid].Value = 0) Then

             Me![otid].Visible = 0

Else

             Me![otid].Visible = -1

End If

 

End Sub

 

Can anyone help me???

 

Thanks in advance.

Alex Mather

Intranet Dev


  Return to Index