I have a form "FrmSearch" that searches table "Customers" and lists the results in a subform, I would like to open a report, then to export these results to a PDF file.
"FrmSearch" has an unbound control "txtcriteria" a "Search Button", an "Export Button" and an imbedded subform "FrmSubSearch".
The search function works fine and populates the subform correctly, my objective is to open a report "SearchRpt" populated with the filtered results as displayed in the subform, I have tried many variations of code but cannot get it to work.
"Search Button" code is
"Export Button" code I am trying is:
When I click "Export Button" I get Error 2103, The report name '[SeachRpt]' you entered in the property sheet or The macro is misspelled or refers to a report that doesn't exist.
Could someone please advise how to overcome this problem.
"FrmSearch" has an unbound control "txtcriteria" a "Search Button", an "Export Button" and an imbedded subform "FrmSubSearch".
The search function works fine and populates the subform correctly, my objective is to open a report "SearchRpt" populated with the filtered results as displayed in the subform, I have tried many variations of code but cannot get it to work.
"Search Button" code is
Code:
Private Sub btnSearch_Click()
Dim strSearch As String
Dim strText As String
strSearch = "SELECT Customers.ID, Customers.OrderDate, Customers.OrderNo, Customers.Customer, Customers.Address, Payment.Payment " _
& "FROM Customers LEFT JOIN Payment ON Customers.OrderNo = Payment.PayNo " _
& "Where [OrderDate] Like '*" & Me.txtcriteria & "*' " _
& " OR [OrderNo] Like '*" & Me.txtcriteria & "*' " _
& " OR [Address] Like '*" & Me.txtcriteria & "*' " _
& " OR [Customer] Like '*" & Me.txtcriteria & "*' " _
& "ORDER BY Customers.[OrderDate] Desc "
Me.Filter = strSearch
Me.FilterOn = True
Me.FrmSubSearch.Form.RecordSource = strSearch
Me.FrmSubSearch.Form.Requery
End Sub
"Export Button" code I am trying is:
Code:
Private Sub Export_Click()
DoCmd.OpenReport "[SeachRpt]", acViewPreview
End Sub
When I click "Export Button" I get Error 2103, The report name '[SeachRpt]' you entered in the property sheet or The macro is misspelled or refers to a report that doesn't exist.
Could someone please advise how to overcome this problem.