troubleshooting Question

DoCmd.OpenReport WHERE field is in TEXT

Avatar of agnelofer1
agnelofer1 asked on
Microsoft Access
4 Comments1 Solution482 ViewsLast Modified:
I need to Print Reports based on WHERE condition. This report is based on a query and the query is the recordet. I intend to create a loop through the recordset and print individual reports till query reaches the last record. The below code works as I want for a numeric field [CandID]
------------------------------------------------------------------------------------------------------------
Public Function PrintReports()
'Declare rsDat as Recorset
Dim rsDat As Recordset

'Here [CandID] is numeric field from [automate_PDF_query]
Set rsDat = CurrentDb.OpenRecordset("Select [CandID] from [automate_PDF_query]")

'Creates a loop to print certificate per record from [automate_PDF_query] until last record
Do
   DoCmd.OpenReport "pdf_certificate", acViewNormal, , "[CandID]=" & rsDat(0)
   rsDat.MoveNext
Loop Until rsDat.EOF

End Function
-------------------------------------------------------------------------------------------------------
I understand the WHERE condition for Do.Cmd OpenReport changes for numeric and text field
So can anyone tell me, how to print certificates using the above code WHERE [CandID], a numeric field is replaced by [Email], a text field. The above code for Do.Cmd OpenReport does not work for a text field like [Email] ????
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros