Parameter Form - Info not pulling up - HELP PLEASE

J

jwr

Following is code for a parameter form that I created to work with my Bill
of Lading Form:

Private Sub Preview_Report_Click()
On Error GoTo Err_Preview_Report_Click

Dim stDocName As String

stDocName = "Bill of lading"
DoCmd.OpenReport stDocName, acPreview

Exit_Preview_Report_Click:
Exit Sub

Err_Preview_Report_Click:
MsgBox Err.Description
Resume Exit_Preview_Report_Click

End Sub


This is the code on the bill of lading:


Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is no data for this report. Canceling report..."
Cancel = -1
End Sub
Private Sub Report_Close()
DoCmd.Close acForm, "ParamControl#"
End Sub
Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "ParamControl#", , , , , acDialog, "Bill of Lading"
If Not IsLoaded("ParamControl#") Then
Cancel = True
End If
End Sub

Query which report is based on - criteria for control number field:
=[forms]![ParamControl#]![Beginning ControlNum] And
<=[forms]![ParamControl#]![Ending ControlNum]


The form "pops up" and asks for my control numbers - beginning and ending.
I then click preview report and I get blank gray screen.
when I run the query, I get empty fields. I have used this same principal
on other paramter forms and it works. Can you see what I have done wrong?

Thank you for your help.
 
J

John Vinson

The form "pops up" and asks for my control numbers - beginning and ending.
I then click preview report and I get blank gray screen.

Put a command button on the popup form to set the form's Visible
property to False. Label this button "Run Report" or "Print" or
something else meaningful to the user.

A form opened in dialog mode stops execution of the calling code - so
your Report is just sitting there waiting to run. The code resumes
execution if the dialog form is closed - no help here, since you need
the form controls for paramters - OR if it is made invisible.

Do remember to close the form in the Report's Close event.

John W. Vinson[MVP]
 
J

jwr

I changed the Preview Report command button to not visible. When I attempt
to run the report, the form pops up asking for my parameters, but now has no
preview report button and thus when I return, I go from one parameter to the
other and never get off the form.
 
J

John Vinson

I changed the Preview Report command button to not visible. When I attempt
to run the report, the form pops up asking for my parameters, but now has no
preview report button and thus when I return, I go from one parameter to the
other and never get off the form.

I'm sorry I wasn't clear!

The "Preview Report" button should be visible.

Its code should make the FORM ITSELF invisible:

Private Sub cmdPreview_Click()
Me.Visible = False
End Sub


John W. Vinson[MVP]
 
J

jwr

I made that change and now I am getting no data. I went to the query and I
am also getting no data.

I am attempting to create a pop-up form and a range of numbers (general) not
dates. Am I doing this incorrectly or is it not possible? If I remove the
criteria of beginning and ending control number, the query and report work.
I have verified that my spelling is correct also.

Thank you,
JR
 
J

John Vinson

I made that change and now I am getting no data. I went to the query and I
am also getting no data.

I am attempting to create a pop-up form and a range of numbers (general) not
dates. Am I doing this incorrectly or is it not possible? If I remove the
criteria of beginning and ending control number, the query and report work.
I have verified that my spelling is correct also.

Since I have no idea what you're doing, I cannot guess what you're
doing wrong...

Please post:

- the name of your popup form
- the name of the controls on the form being used for criteria
- the SQL of the Query upon which your report is based
- the Report's Open event code
- the Report's Close event code
- the command button's code


John W. Vinson[MVP]
 
J

jwr

My answers are beneath you requests. Thank you

John Vinson said:
- the name of your popup form ParamControl#
- the name of the controls on the form being used for criteria ControlNum

- the SQL of the Query upon which your report is based

SELECT Orders.PurchaseOrderNumber, Orders.ShipName, Orders.ShipAddress,
Orders.ShipCity, Orders.ShipStateOrProvince, Orders.ShipPostalCode,
Orders.ShipCountry, Orders.ShipPhoneNumber, Orders.MarkForName,
Orders.MarkForAddress, Orders.MarkForCountry, Orders.MarkForPostalCode,
[Order Details].Quantity, Products.ProductCode, Products.ProductName,
Products.UnitWeight, [Quantity]*[UnitWeight] AS [Total Weight],
Customers.ControlNum, [Order Details].SerialNum, Orders.ShipDate,
Dealer.DealerName, Dealer.ContactPerson, Dealer.City, Dealer.State,
[Shipping Methods].ShippingMethod, [Shipping Methods].ShippingMethodAddress,
[Shipping Methods].ShippingMethodCity, [Shipping
Methods].ShippingMethodState, [Shipping Methods].ShippingMethodContact,
[Shipping Methods].ShippingMethodPhoneNum
FROM (Dealer INNER JOIN ([Shipping Methods] RIGHT JOIN (Customers INNER JOIN
Orders ON Customers.CustomerID = Orders.CustomerID) ON [Shipping
Methods].ShippingMethodID = Orders.ShippingMethodID) ON Dealer.DealerID =
Orders.DealerID) INNER JOIN ((Contracts INNER JOIN (SIN INNER JOIN Products
ON SIN.SINID = Products.SINID) ON Contracts.ContractID =
Products.ContractID) INNER JOIN [Order Details] ON Products.ProductID =
[Order Details].ProductID) ON Orders.OrderID = [Order Details].OrderID
WHERE (((Customers.ControlNum)>=[forms]![ParamControl#]![Beginning
ControlNum] And (Customers.ControlNum)<=[forms]![ParamControl#]![Ending
ControlNum]));



- the Report's Open event code
- the Report's Close event code

Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is no data for this report. Canceling report..."
Cancel = -1
End Sub
Private Sub Report_Close()
DoCmd.Close acForm, "ParamControl#"
End Sub
Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "ParamControl#", , , , , acDialog, "Bill of Lading"
If Not IsLoaded("ParamControl#") Then
Cancel = True
End If
End Sub


- the command button's code
Private Sub Preview_Report_Click()
On Error GoTo Err_Preview_Report_Click

Dim stDocName As String

stDocName = "Bill of Lading"
DoCmd.OpenReport stDocName, acPreview

Exit_Preview_Report_Click:
Exit Sub

Err_Preview_Report_Click:
MsgBox Err.Description
Resume Exit_Preview_Report_Click

End Sub

Private Sub Command7_Click()
Me.Visible = False
End Sub
 
Top