Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"The expression is typed incorrectly or it is too complex to be evalua

Status
Not open for further replies.

Jackie

MIS
Feb 9, 2000
148
US
I wish to run a report for a specific criteria. I get an error message on the DoCmd.OpenReport command. The error message states "The expression is typed incorrectly or it is too complex to be evaluated".

The query referenced (qry_general_letter) is based on another query which is based on a table. It is the data source for the report specified in the OpenReport command.

Is the syntax incorrect?
Or does the Where clause of the OpenReport function not allow a query based upon a query?

DoCmd.OpenReport "rpt_General_Letter", acViewPreview, "", "[qry_General_Letter].[transaction number] = """ & strTransNo & """"



Below is surrounding code:

sql = "SELECT [Leave Bank Transaction Log].[transaction number], [Leave Bank Transaction Log].[transaction code], " _
& "[Leave Bank Transaction Log].VLtype FROM [Leave Bank Transaction Log]" _
& " WHERE " _
& "([Leave Bank Transaction Log].[transaction number]>=" & [Forms]![frm_letter_generation]![begintrans] & ")" _
& &quot; And ([Leave Bank Transaction Log].[transaction number]<=&quot; & [Forms]![frm_letter_generation]![endtrans] & &quot;)&quot; _
& &quot; AND ([Leave Bank Transaction Log].[transaction code]=&quot;&quot;GC&quot;&quot;)&quot; _
& &quot; AND ([Leave Bank Transaction Log].VLtype=&quot;&quot;VLBP&quot;&quot;);&quot;


Set CheckForRecords = CurrentDb.OpenRecordset(sql, DB_OPEN_DYNASET)

With CheckForRecords
If .RecordCount > 0 Then

Do While Not .EOF

strTransNo = .Fields(&quot;[Transaction Number]&quot;)

DoCmd.OpenReport &quot;rpt_General_Letter&quot;, acViewPreview, &quot;&quot;, &quot;[qry_General_Letter].[transaction number] = &quot;&quot;&quot; & strTransNo & &quot;&quot;&quot;&quot;


.MoveNext
Loop

MsgBox &quot;General Contribution Letters Completed&quot;

Else
' MsgBox &quot;No data selected for general contribution letters.&quot;
.Close
End If
End With
 
Try this
DoCmd.OpenReport &quot;rpt_General_Letter&quot;, acViewPreview,, &quot;[transaction number] = '&quot; & strTransNo & &quot;'&quot;

Paul

 
Thank you for responding.

Error message still occurs.

I think the problem is in referencing the transaction number.

Any ideas would be appreciated.

-jackie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top