preview report and setting recordsource

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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
 
Back
Top