preview report and setting recordsource

G

Guest

this is my code:
Private Sub Command26_Click()
Dim stDocName As String
Dim search As String

search = "SELECT asbestosbridge.* FROM asbestosbridge;"

stDocName = "cbin"
DoCmd.OpenReport stDocName, acViewPreview

Reports![cbin].RecordSource = search

End Sub
It is telling me I can't set the recordsource for print preview. Is there a
way to do this? I would like to use code so I can have a form for user
criteria selection.
 
A

Alex Dybenko

You can change property RecordSource value before report runs, in Open
event or example.
so you can store it value on a hidden textbox of a form, and in open report
event read it and assign to RecordSource
 

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