I have a Subform which has a datasheet, a textbox and a button. I want to be able to input the records on the datasheet onto a report using the value on the textbox by clicking the subform button.
The report has a record source linked to query qryrpt. If I put a criteria on the qrypt, it keeps asking for a parameter to be entered. I want to avoid this since the parameter is the same as the value on the subform textbox. Is there a better way of doing this? Could someone please point me to the right direction?
Private Sub createreport_Click()
Dim Task As String
Dim SearchResults
Me.txtSearch.Value = Me.SearchResults
Task = "SELECT * FROM tblA WHERE ((Location Like ""*" & SearchResults &
"*""))"
Me.frmDatasheet.Form.RecordSource = Task
Me.SearchResults.Value = Reports!rptName.txtheading
DoCmd.OpenReport "rptName", acViewPreview
End Sub