Can anyone tell me what is wrong here?

G

Guest

Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
' Then close the Print Sales Reports Dialog form.

Dim strWhereOpType As String

strWhereOpType = "Operation Type Description = Forms![Product
Dialog]!SelectOpType"

Select Case Me!ReportToPrint
Case 1
DoCmd.OpenReport "Manufacturer List", PrintMode
Case 2
DoCmd.OpenReport "DateContacted", PrintMode
Case 3
If IsNull(Forms![Product Dialog]!SelectOpType) Then
DoCmd.OpenForm "PopUp Choose"
Else
DoCmd.OpenReport "Manufacturer by Category", PrintMode, ,
strWhereOpType
End If
End Select
DoCmd.CLOSE acForm, "Product Dialog"

Exit_Preview_Click:
Exit Sub

Err_Preview_Click:
Resume Exit_Preview_Click

End Sub

Private Sub Cancel_Click()
' This code created by Command Button Wizard.
On Error GoTo Err_Cancel_Click

' Close form.
DoCmd.CLOSE

Exit_Cancel_Click:
Exit Sub

Err_Cancel_Click:
MsgBox Err.Description
Resume Exit_Cancel_Click

End Sub


Private Sub Preview_Click()
' Preview selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.

PrintReports acPreview

End Sub




Private Sub Print_Click()
' Print selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.

PrintReports acNormal

End Sub



Private Sub ReportToPrint_AfterUpdate()
' Enable SelectCategory combo box if user selected Manufacturer by Category
' report.

Const conManufacturerByCategory = 3

If Me!ReportToPrint.Value = conManufacturerByCategory Then
Me!SelectOpType.Enabled = True
Else
Me!SelectOpType.Enabled = False
End If

End Sub


****************************************************
I have check and checked again and all the information is correct, yet when
I go to the select Op type, it will neither print nor preview. All other
options work. Why is it not recognizing the selected category?
 
D

David Lloyd

Tammy:

One suggestion would be to use brackets in your WHERE clause. For example:

strWhereOpType = "[Operation Type Description] = Forms![Product
Dialog]!SelectOpType"

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
' Then close the Print Sales Reports Dialog form.

Dim strWhereOpType As String

strWhereOpType = "Operation Type Description = Forms![Product
Dialog]!SelectOpType"

Select Case Me!ReportToPrint
Case 1
DoCmd.OpenReport "Manufacturer List", PrintMode
Case 2
DoCmd.OpenReport "DateContacted", PrintMode
Case 3
If IsNull(Forms![Product Dialog]!SelectOpType) Then
DoCmd.OpenForm "PopUp Choose"
Else
DoCmd.OpenReport "Manufacturer by Category", PrintMode, ,
strWhereOpType
End If
End Select
DoCmd.CLOSE acForm, "Product Dialog"

Exit_Preview_Click:
Exit Sub

Err_Preview_Click:
Resume Exit_Preview_Click

End Sub

Private Sub Cancel_Click()
' This code created by Command Button Wizard.
On Error GoTo Err_Cancel_Click

' Close form.
DoCmd.CLOSE

Exit_Cancel_Click:
Exit Sub

Err_Cancel_Click:
MsgBox Err.Description
Resume Exit_Cancel_Click

End Sub


Private Sub Preview_Click()
' Preview selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.

PrintReports acPreview

End Sub




Private Sub Print_Click()
' Print selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.

PrintReports acNormal

End Sub



Private Sub ReportToPrint_AfterUpdate()
' Enable SelectCategory combo box if user selected Manufacturer by Category
' report.

Const conManufacturerByCategory = 3

If Me!ReportToPrint.Value = conManufacturerByCategory Then
Me!SelectOpType.Enabled = True
Else
Me!SelectOpType.Enabled = False
End If

End Sub


****************************************************
I have check and checked again and all the information is correct, yet when
I go to the select Op type, it will neither print nor preview. All other
options work. Why is it not recognizing the selected category?
 
G

Guest

My suggestion is to change:

strWhereOpType = "Operation Type Description = Forms![Product
Dialog]!SelectOpType"

for this if SelectOpType is numeric:

strWhereOpType = "Operation Type Description = " & Forms![Product
Dialog]!SelectOpType

or for this if it is text:

strWhereOpType = "Operation Type Description = """ & Forms![Product
Dialog]!SelectOpType & """"

Mauricio Silva
 

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