Code to Launch report from form problem

  • Thread starter Thread starter smcgrath via AccessMonster.com
  • Start date Start date
S

smcgrath via AccessMonster.com

I am using the following code on a form to print a report - I would like to
select a processor and have all of their accounts show on the report. Query
is working fine but when I preview the report with this code, I have a blank
report. processor Initials is a text field-Do I have the quotes messed up?
No matter what I change them to I get no results on the report. Any ideas?


Dim StrWhere As String

'Select Processor
If IsNull(cboInit) = False Then
If StrWhere <> "" Then
StrWhere = StrWhere & " and "
End If
StrWhere = StrWhere & "processorInit = '" & cboInit & "'"
DoCmd.OpenReport "RptToBeDischarged", acViewPreview, , StrWhere
End If
 
You sure cboInit is returning what you think it is?

Try putting a MsgBox StrWhere just before your DoCmd.OpenReport statement.
 
As Mr. Steele said, check cbolnit (make sure that it is spelled
correctly) and that it is not defined as a number (long, integer,
etc.). If it is defined as a number, the quotes will need to be
eliminated and replaced as follows:
StrWhere = StrWhere & "processorInit = " & cboInit
 
Back
Top