Two message boxes

R

Rockn

I have two message boxes that fire off when I am going to print a report to
determine what will show up on the report as far as fields. The first
message box is to hide the customer price on a quote, if you answer yes it
sets a checkbox on the initial form to true. The next message box is to show
or hide the changes made to the quote on the report. If I say vbyes to both
of the message boxes the customer pricing will not be hidden as the checkbox
is getting set back to false. I am not sure why it is toggling, but it works
if I answer yes to the first and no to hte second. It may just be the order
in which the events are happening or the initial state of the checkbox. Code
below:

Case 1

If IsNull(Me.[Text147]) And IsNull(Me.[Text133]) Then
rptType = "rpt_CustomerCopy"
End If
If IsNull(Me.[Text147]) And Not (IsNull(Me.Text133)) Then
rptType = "rpt_CustomerCopyDisc"
End If
If Not (IsNull(Me.Text147)) And IsNull(Me.[Text133]) Then
rptType = "rpt_CustomerCopyAdd"
End If
If Not (IsNull(Me.Text147)) And Not (IsNull(Me.[Text133])) Then
rptType = "rpt_CustomerCopyBoth"
End If

HideCost = MsgBox("Hide Homeowner Cost?", vbYesNo, "Hide Cost")
If HideCost = vbYes Then
Me.Check161.Value = True
End If
If HideCost = vbNo Then
Me.Check161.Value = False
End If


LResponse = MsgBox("Show Changes on Report?", vbYesNo, "Print Changes?")
DoCmd.OpenReport rptType, acPreview, , "[JOB_ID]= " & Me.[JOB_ID]
If LResponse = vbYes Then
Reports(rptType).Report!rpt_Change.Visible = True
End If

DoCmd.Maximize
DoCmd.RunCommand acCmdZoom100
 
R

Rockn

On the report I have an onOpen event that checks the status of the checkbox
on the previous form.

Private Sub Report_Open(Cancel As Integer)
If Form_frm_JobSelect.Check161.Value = True Then
Me.HMCost.Visible = False
Me.Label32.Visible = False
Else
Me.HMCost.Visible = True
Me.Label32.Visible = True
End If
End Sub

I think you are correct that it may need to go in the OnFormat event handler
for the report section.
I will give that a go and see what happens.


J_Goddard via AccessMonster.com said:
Hi -

I notice two problems. First, you set the value of me.check161 based on a
user response - but what do you do with it? How does the report know what
check161 is?

Secondly, you are trying to change the visibility of rpt_Change AFTER you
produce the report, which doesn't work.

You need to have the code in the report itself determine what fields to
show,
either by referencing the form's controls e.g.

If Forms!MyForm!check161 = true then.... (the form must be open)

or by passing the information to the report through the OpenArgs parameter
of
the docmd.openReport statement.

You would probably want to put the code in the On Format event of the
appropriate section of the report.

HTH

John




I have two message boxes that fire off when I am going to print a report
to
determine what will show up on the report as far as fields. The first
message box is to hide the customer price on a quote, if you answer yes it
sets a checkbox on the initial form to true. The next message box is to
show
or hide the changes made to the quote on the report. If I say vbyes to
both
of the message boxes the customer pricing will not be hidden as the
checkbox
is getting set back to false. I am not sure why it is toggling, but it
works
if I answer yes to the first and no to hte second. It may just be the
order
in which the events are happening or the initial state of the checkbox.
Code
below:

Case 1

If IsNull(Me.[Text147]) And IsNull(Me.[Text133]) Then
rptType = "rpt_CustomerCopy"
End If
If IsNull(Me.[Text147]) And Not (IsNull(Me.Text133)) Then
rptType = "rpt_CustomerCopyDisc"
End If
If Not (IsNull(Me.Text147)) And IsNull(Me.[Text133]) Then
rptType = "rpt_CustomerCopyAdd"
End If
If Not (IsNull(Me.Text147)) And Not (IsNull(Me.[Text133])) Then
rptType = "rpt_CustomerCopyBoth"
End If

HideCost = MsgBox("Hide Homeowner Cost?", vbYesNo, "Hide Cost")
If HideCost = vbYes Then
Me.Check161.Value = True
End If
If HideCost = vbNo Then
Me.Check161.Value = False
End If

LResponse = MsgBox("Show Changes on Report?", vbYesNo, "Print
Changes?")
DoCmd.OpenReport rptType, acPreview, , "[JOB_ID]= " & Me.[JOB_ID]
If LResponse = vbYes Then
Reports(rptType).Report!rpt_Change.Visible = True
End If

DoCmd.Maximize
DoCmd.RunCommand acCmdZoom100
 

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