Report Selection from Po-Up Choice?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I use MS Access 2000.

Is there a way to automatically select a report to be executed from choices
made from a Pop-Up Query form?

There are 6 possible reports that can be called. There are 2 drop-down
combo boxes on the Pop-Up Query form. There are also 6 possible choices on
one of the combo boxes on the Pop-Up Query form that determines which report
should be run.

My skill level is probably “medium.†I would appreciate any help offered.
 
I'm not sure what you mean by Pop-Up Query so I'll assume that this is a form
that asks for some information. Use the control's After Update event to run
the report. You can use an If...Then or Select Case conditional to make the
decision. For example:

If Me.ComboBox1 = "Report1" then
DoCmd.OpenReport "Report1"
...

or if the combobox selections correspond exactly to the report names:

DoCmd.OpenReport Me.ComboBox1
 
Thanks Kingston for your help!

Yes, my Pop-Up Query is a form.

You said, "Use the control's AfterUpdate event..." The form and the Combo
Box offer an AfterUpdate event option. My preview report control button does
NOT. I am not sure where or how to place the code.

This is the code I wrote for the AfterUpdate events:

Private Sub MemberTypeListPUP_AfterUpdate()
If Me.MemberTypeListPUP = "Broker, Member" Then
DoCmd.OpenReport "INVBrokerMemberReport"
End
Else
If Me.MemberTypeListPUP = "Broker, Non-Member" Then
DoCmd.OpenReport "INVBrokerNonMemberReport"
End
Else
If Me.MemberTypeListPUP = "Operator, Member" Then
DoCmd.OpenReport "INVOperatorMemberReport"
End
Else
If Me.MemberTypeListPUP = "Operator, Non-Member" Then
DoCmd.OpenReport "INVOperatorNonMemberReport"
End
Else
If Me.MemberTypeListPUP = "Supplier, Member" Then
DoCmd.OpenReport "INVSupplierMemberReport"
End
Else
If Me.MemberTypeListPUP = "Supplier, Non-Member" Then
DoCmd.OpenReport "INVSupplierNonMemberReport"
End
End Sub

I do not know if this code is correct.

For my preview button, I have this code:

Dim stDocName As String

stDocName = "What Do I Put here????"
DoCmd.OpenReport stDocName, acPreview
DoCmd.Close acForm, "Group Invoice Pop-Up Form", acSaveYes
Exit_PreviewInvoicesCommand_Click:
Exit Sub

Err_PreviewInvoicesCommand_Click:
MsgBox Err.Description
Resume Exit_PreviewInvoicesCommand_Click

End Sub

NOTE: The Preview Control Does NOT offer an “AfterUpdate†Event

As a result of my confusion, I am unable to get the effect I want. Where am
I going wrong? Thanks in advance for your help.
 
I'm going to guess what you want the preview button because I'm not sure I
fully understand your post. When you make a selection in a combobox, a
report opens. However, I'm guessing that you don't want this to happen and
you want the button to open the report. If this is the case, use the
button's On Click event to open the correct report instead (and disable your
code for the comboboxes).

As an aside, don't be afraid to experiment with the different control events.
Most of them are straightforward. In design view, select a control and view
its properties. Take a look at the options available in the Event tab and
explore them. Good luck.
 
Hi Kingston:

Thanks again for your help!

My "Dialog Box" pop-up (what I referred to as Pop-Up Query Form) has 2 combo
boxes and 2 control buttons. 1 button cancels and closes the Dialog Box and
the other button activates an event that PREVIEWS my reports (based upon my
1st combo box selection).

I've rewritten the code as follows:

Private Sub PreviewInvoicesCommand_Click()
On Error GoTo Err_PreviewInvoicesCommand_Click

If Me.MemberTypeListPUP = "Broker, Member" Then
DoCmd.OpenReport "INVBrokerMemberReport"
DoCmd.Close acForm, "Group Invoice Pop-Up Form", acSaveYes
ElseIf Me.MemberTypeListPUP = "Broker, Non-Member" Then
DoCmd.OpenReport "INVBrokerNonMemberReport"
DoCmd.Close acForm, "Group Invoice Pop-Up Form", acSaveYes
ElseIf Me.MemberTypeListPUP = "Operator, Member" Then
DoCmd.OpenReport "INVOperatorMemberReport"
DoCmd.Close acForm, "Group Invoice Pop-Up Form", acSaveYes
ElseIf Me.MemberTypeListPUP = "Operator, Non-Member" Then
DoCmd.OpenReport "INVOperatorNonMemberReport"
DoCmd.Close acForm, "Group Invoice Pop-Up Form", acSaveYes
ElseIf Me.MemberTypeListPUP = "Supplier, Member" Then
DoCmd.OpenReport "INVSupplierMemberReport"
DoCmd.Close acForm, "Group Invoice Pop-Up Form", acSaveYes
Else
DoCmd.OpenReport "INVSupplierNonMemberReport"
DoCmd.Close acForm, "Group Invoice Pop-Up Form", acSaveYes
End
End If

Exit_PreviewInvoicesCommand_Click:
Exit Sub

Err_PreviewInvoicesCommand_Click:
MsgBox Err.Description
Resume Exit_PreviewInvoicesCommand_Click

End Sub


Everything works correctly now EXCEPT that the reports are PRINTED, not
Previewed, as I would like. Perhaps you can see why this is happening and
how I might remedy it! Thanks again for all your terrific help.
 
Use the option acViewPreview in your OpenReport command:

DoCmd.OpenReport "INVBrokerNonMemberReport", acViewPreview

When you type a comma after your existing command, a selection list should
pop-up. Select the preview option.
 
Hi Kingston:

Thanks again for your help and support.

The report now runs BUT it does not appear. It is not the top (visible)
window. If I go to the Top Page Bar And Click WINDOW, The report is the 2nd
item on the list. How can I make the report be the 1st item and thus be be
visible after clicking the "Preview Report" control button. I'm almost
there! Thanks again!
 
Your pop-up form will always appear on top. You can close or minimize it
after the report is opened, or you can change the form to not be a pop-up.
Howver, since reports cannot be pop-up windows (AFAIK), your report will
always appear under a pop-up form.
 

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

Back
Top