Dan
Dan

Reputation: 3

using a textbox value as string in Access

I have a table that feeds several reports. For each customer, for example, I have a different report with his own logo, etc, but all these reports gets their data from one table. Each report has a different name which is attached to the customer name in a different column. I have then a form where I select the customer and the respective report name comes up in a textbox. I want to open each individual report with a command button using the following command: DoCmd.OpenReport " REPORT_NAME ", acViewPreview

"REPORT_NAME" has to be replaced with the string value from the textbox for each individual customer from the opening form.

What command should I use to solve this?

I hope this is not too confusing.

Thanks in advance.

Upvotes: 0

Views: 178

Answers (1)

Andre
Andre

Reputation: 27634

Not sure if I'm missing something, but you can simply do

DoCmd.OpenReport Me!theTextboxWithReportName, acViewPreview

or a little more elaborate

Dim strReport As String
strReport = Nz(Me!theTextboxWithReportName, "")
If strReport <> "" Then
    DoCmd.OpenReport strReport, acViewPreview
End If

Upvotes: 1

Related Questions