Form won't open report from preview button

J

jwr

I created a packing list form that I want to open and open the packing list
report when I select the preview packing list command button on the customer
form. I get the form to open, but I do not get the report behind the print
packing list form to open. What am I missing? Do I need another command to
open the Packing List Report? thanks in advance, JR



CODE BEHIND "PREVIEW PACKING LIST" ON ORDERS BY CUSTOMER FORM:

Private Sub Preview_Packing_List_Click()
On Error GoTo Err_Preview_Packing_List_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Packing List"
Me.Dirty = False
stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Preview_Packing_List_Click:
Exit Sub

Err_Preview_Packing_List_Click:
MsgBox Err.Description
Resume Exit_Preview_Packing_List_Click

End Sub




CODE BEHIND "PRINT PACKING LIST FORM"

Private Sub Form_Open(Cancel As Integer)
If Not IsLoaded("Orders by Customer") Then
MsgBox "Open the Print Packing List form using the Preview Packing
List button on the Orders by Customer form."
Cancel = True
End If
End Sub
Private Sub OK_Click()
Me.Visible = False
End Sub
Private Sub Cancel_Click()
DoCmd.Close acForm, "Print Packing List"
End Sub
 
W

Wayne Morgan

Yes, each action you want to perform will require a command. You have a
command in the code below to open the form, but nothing to open the report.
The command for that is similar to the one you used to open the form, it is
DoCmd.OpenReport. The default open for a report is to print it, if you want
to preview it be sure to add the acViewPreview argument.
 
J

jwr

I now have the problem of getting the pop-up form to close when the report
appears on the screen. The pop-up form is over the top of the report. How
do I change this?
thanks
Wayne Morgan said:
Yes, each action you want to perform will require a command. You have a
command in the code below to open the form, but nothing to open the report.
The command for that is similar to the one you used to open the form, it is
DoCmd.OpenReport. The default open for a report is to print it, if you want
to preview it be sure to add the acViewPreview argument.

--
Wayne Morgan
MS Access MVP


jwr said:
I created a packing list form that I want to open and open the packing
list
report when I select the preview packing list command button on the
customer
form. I get the form to open, but I do not get the report behind the
print
packing list form to open. What am I missing? Do I need another command
to
open the Packing List Report? thanks in advance, JR



CODE BEHIND "PREVIEW PACKING LIST" ON ORDERS BY CUSTOMER FORM:

Private Sub Preview_Packing_List_Click()
On Error GoTo Err_Preview_Packing_List_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Packing List"
Me.Dirty = False
stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Preview_Packing_List_Click:
Exit Sub

Err_Preview_Packing_List_Click:
MsgBox Err.Description
Resume Exit_Preview_Packing_List_Click

End Sub




CODE BEHIND "PRINT PACKING LIST FORM"

Private Sub Form_Open(Cancel As Integer)
If Not IsLoaded("Orders by Customer") Then
MsgBox "Open the Print Packing List form using the Preview Packing
List button on the Orders by Customer form."
Cancel = True
End If
End Sub
Private Sub OK_Click()
Me.Visible = False
End Sub
Private Sub Cancel_Click()
DoCmd.Close acForm, "Print Packing List"
End Sub
 
W

Wayne Morgan

Are you using the popup form as a data or filter source for your report? If
so, you probably don't want to close it until you close the report. However,
you can hide it by setting its Visible property to False. Use the IsLoaded()
function that you are currently using in the 2nd event you published in your
report's Close event to see if the popup form is still open. If it is, close
it using the DoCmd.Close command.

--
Wayne Morgan
MS Access MVP


jwr said:
I now have the problem of getting the pop-up form to close when the report
appears on the screen. The pop-up form is over the top of the report.
How
do I change this?
thanks
message
Yes, each action you want to perform will require a command. You have a
command in the code below to open the form, but nothing to open the report.
The command for that is similar to the one you used to open the form, it is
DoCmd.OpenReport. The default open for a report is to print it, if you want
to preview it be sure to add the acViewPreview argument.

--
Wayne Morgan
MS Access MVP


jwr said:
I created a packing list form that I want to open and open the packing
list
report when I select the preview packing list command button on the
customer
form. I get the form to open, but I do not get the report behind the
print
packing list form to open. What am I missing? Do I need another command
to
open the Packing List Report? thanks in advance, JR



CODE BEHIND "PREVIEW PACKING LIST" ON ORDERS BY CUSTOMER FORM:

Private Sub Preview_Packing_List_Click()
On Error GoTo Err_Preview_Packing_List_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Packing List"
Me.Dirty = False
stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Preview_Packing_List_Click:
Exit Sub

Err_Preview_Packing_List_Click:
MsgBox Err.Description
Resume Exit_Preview_Packing_List_Click

End Sub




CODE BEHIND "PRINT PACKING LIST FORM"

Private Sub Form_Open(Cancel As Integer)
If Not IsLoaded("Orders by Customer") Then
MsgBox "Open the Print Packing List form using the Preview Packing
List button on the Orders by Customer form."
Cancel = True
End If
End Sub
Private Sub OK_Click()
Me.Visible = False
End Sub
Private Sub Cancel_Click()
DoCmd.Close acForm, "Print Packing List"
End Sub
 
J

jwr

Let me try again. Below is the code behind my pop-up form "Print Packing
List".

Private Sub Form_Open(Cancel As Integer)
If Not IsLoaded("Orders by Customer") Then
MsgBox "Open the Print Packing List form using the Preview Packing
List button on the Orders by Customer form."
Cancel = True
End If
End Sub
Private Sub OK_Click()
Me.Visible = False

End Sub

Private Sub Cancel_Click()
DoCmd.Close acForm, "Print Packing List"
Me.Visible = False
End Sub



This is the code behind the "Preview (command button) Packing List" at the
bottom of the pop-up form above.

This form is used as a filter source for my report.

I have Visible = false already.



I want the pop-up form to open when I select the Preview command button on
the bottom of my Orders by Customer form. Code follows:

Private Sub Command38Preview_Packing_List_Click()
On Error GoTo Err_Command38Preview_Packing_List_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Print Packing List"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command38Preview_Packing_List_Click:
Exit Sub

Err_Command38Preview_Packing_List_Click:
MsgBox Err.Description
Resume Exit_Command38Preview_Packing_List_Click

End Sub


When I select the Preview Packing List command button on the "Orders by
Customers", this information should be for the customer ONLY and no others.
The pop-up form appears, I click the preview button, and the report appears
behind the pop-up form. When I close the pop-up form, I get a "bug" error,
I close that error message, close my orders form and the packing list form
is still on the screen.

Maybe I have too many commands, such as preview on the pop-up form and
preview on the orders by customers. I want the Orders by Customers form to
be the place for the preview option.

Hopefully you can follow me on this. I am relatively new to code such as
this and I may not be understanding your reply.
Thank you for your assistance.
JR
____________________________________________________________________________
_____________________________________________










Private Sub Preview_Packing_List_Click()
On Error GoTo Err_Preview_Packing_List_Click

Dim stDocName As String

stDocName = "Packing List"
DoCmd.OpenReport stDocName, acPreview

Exit_Preview_Packing_List_Click:
Exit Sub

Err_Preview_Packing_List_Click:
MsgBox Err.Description
Resume Exit_Preview_Packing_List_Click

End Sub
Wayne Morgan said:
Are you using the popup form as a data or filter source for your report? If
so, you probably don't want to close it until you close the report. However,
you can hide it by setting its Visible property to False. Use the IsLoaded()
function that you are currently using in the 2nd event you published in your
report's Close event to see if the popup form is still open. If it is, close
it using the DoCmd.Close command.

--
Wayne Morgan
MS Access MVP


jwr said:
I now have the problem of getting the pop-up form to close when the report
appears on the screen. The pop-up form is over the top of the report.
How
do I change this?
thanks
message
Yes, each action you want to perform will require a command. You have a
command in the code below to open the form, but nothing to open the report.
The command for that is similar to the one you used to open the form,
it
is
DoCmd.OpenReport. The default open for a report is to print it, if you want
to preview it be sure to add the acViewPreview argument.

--
Wayne Morgan
MS Access MVP


I created a packing list form that I want to open and open the packing
list
report when I select the preview packing list command button on the
customer
form. I get the form to open, but I do not get the report behind the
print
packing list form to open. What am I missing? Do I need another command
to
open the Packing List Report? thanks in advance, JR



CODE BEHIND "PREVIEW PACKING LIST" ON ORDERS BY CUSTOMER FORM:

Private Sub Preview_Packing_List_Click()
On Error GoTo Err_Preview_Packing_List_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Packing List"
Me.Dirty = False
stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Preview_Packing_List_Click:
Exit Sub

Err_Preview_Packing_List_Click:
MsgBox Err.Description
Resume Exit_Preview_Packing_List_Click

End Sub




CODE BEHIND "PRINT PACKING LIST FORM"

Private Sub Form_Open(Cancel As Integer)
If Not IsLoaded("Orders by Customer") Then
MsgBox "Open the Print Packing List form using the Preview Packing
List button on the Orders by Customer form."
Cancel = True
End If
End Sub
Private Sub OK_Click()
Me.Visible = False
End Sub
Private Sub Cancel_Click()
DoCmd.Close acForm, "Print Packing List"
End Sub
 
W

Wayne Morgan

In the button where you open the report from the popup form, you need to
hide the popup form. You are hiding it in the Cancel button's event if you
choose to not open the report and also in the Ok button's click event, but
the Ok button doesn't open the report (i.e. no DoCmd.OpenReport command).
How are you opening the report? Also, in the Cancel button, I would probably
close the popup instead of hiding it unless you have another need for it.

--
Wayne Morgan
MS Access MVP


jwr said:
Let me try again. Below is the code behind my pop-up form "Print Packing
List".

Private Sub Form_Open(Cancel As Integer)
If Not IsLoaded("Orders by Customer") Then
MsgBox "Open the Print Packing List form using the Preview Packing
List button on the Orders by Customer form."
Cancel = True
End If
End Sub
Private Sub OK_Click()
Me.Visible = False

End Sub

Private Sub Cancel_Click()
DoCmd.Close acForm, "Print Packing List"
Me.Visible = False
End Sub



This is the code behind the "Preview (command button) Packing List" at the
bottom of the pop-up form above.

This form is used as a filter source for my report.

I have Visible = false already.



I want the pop-up form to open when I select the Preview command button on
the bottom of my Orders by Customer form. Code follows:

Private Sub Command38Preview_Packing_List_Click()
On Error GoTo Err_Command38Preview_Packing_List_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Print Packing List"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command38Preview_Packing_List_Click:
Exit Sub

Err_Command38Preview_Packing_List_Click:
MsgBox Err.Description
Resume Exit_Command38Preview_Packing_List_Click

End Sub


When I select the Preview Packing List command button on the "Orders by
Customers", this information should be for the customer ONLY and no
others.
The pop-up form appears, I click the preview button, and the report
appears
behind the pop-up form. When I close the pop-up form, I get a "bug"
error,
I close that error message, close my orders form and the packing list form
is still on the screen.

Maybe I have too many commands, such as preview on the pop-up form and
preview on the orders by customers. I want the Orders by Customers form
to
be the place for the preview option.

Hopefully you can follow me on this. I am relatively new to code such as
this and I may not be understanding your reply.
Thank you for your assistance.
JR
____________________________________________________________________________
_____________________________________________










Private Sub Preview_Packing_List_Click()
On Error GoTo Err_Preview_Packing_List_Click

Dim stDocName As String

stDocName = "Packing List"
DoCmd.OpenReport stDocName, acPreview

Exit_Preview_Packing_List_Click:
Exit Sub

Err_Preview_Packing_List_Click:
MsgBox Err.Description
Resume Exit_Preview_Packing_List_Click

End Sub
message
Are you using the popup form as a data or filter source for your report? If
so, you probably don't want to close it until you close the report. However,
you can hide it by setting its Visible property to False. Use the IsLoaded()
function that you are currently using in the 2nd event you published in your
report's Close event to see if the popup form is still open. If it is, close
it using the DoCmd.Close command.

--
Wayne Morgan
MS Access MVP


jwr said:
I now have the problem of getting the pop-up form to close when the report
appears on the screen. The pop-up form is over the top of the report.
How
do I change this?
thanks
message
Yes, each action you want to perform will require a command. You have
a
command in the code below to open the form, but nothing to open the
report.
The command for that is similar to the one you used to open the form, it
is
DoCmd.OpenReport. The default open for a report is to print it, if you
want
to preview it be sure to add the acViewPreview argument.

--
Wayne Morgan
MS Access MVP


I created a packing list form that I want to open and open the packing
list
report when I select the preview packing list command button on the
customer
form. I get the form to open, but I do not get the report behind
the
print
packing list form to open. What am I missing? Do I need another
command
to
open the Packing List Report? thanks in advance, JR



CODE BEHIND "PREVIEW PACKING LIST" ON ORDERS BY CUSTOMER FORM:

Private Sub Preview_Packing_List_Click()
On Error GoTo Err_Preview_Packing_List_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Packing List"
Me.Dirty = False
stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Preview_Packing_List_Click:
Exit Sub

Err_Preview_Packing_List_Click:
MsgBox Err.Description
Resume Exit_Preview_Packing_List_Click

End Sub




CODE BEHIND "PRINT PACKING LIST FORM"

Private Sub Form_Open(Cancel As Integer)
If Not IsLoaded("Orders by Customer") Then
MsgBox "Open the Print Packing List form using the Preview
Packing
List button on the Orders by Customer form."
Cancel = True
End If
End Sub
Private Sub OK_Click()
Me.Visible = False
End Sub
Private Sub Cancel_Click()
DoCmd.Close acForm, "Print Packing List"
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