Hi,
I have the following forms setup:
frm_Main (Switchboard)
frm_Customers (Form)
frm_SalesDetailsSub (SubForm on frmCustomers showing basic details of items they have bought)
On frm_Main I can search for Customers by Surname using the following code behind a search button on the form:
On Error GoTo Err_Handler
Dim stQry
Dim stDocName As String
stQry = SearchSurname() 'Query containing tblCustomers
stDocName = "frm_Customers"
DoCmd.OpenForm stDocName, acNormal, stQry, "((([tbl_Customers].[Customer_LName])like[Customer Surname?]& ""*""))"
Err_Handler:
If Err.Number = 2501 Then
Resume Next
Else
Resume Next
End If
This works fine, however I also want to search by items on the subform frm_SalesDetailsSub by using another button on frm_Main. I have tried code like the one shown below.
On Error GoTo Err_Handler
Dim stQry
Dim stDocName As String
stQry = SearchSaleItem() 'Query containing tblCustomers and tblSales Items linked via ID
stDocName = "frm_Customers"
DoCmd.OpenForm stDocName, acNormal, stQry, "((([tbl_Sales_Details].[Sales_Details])like [Item Description?]& ""*""))"
Err_Handler:
If Err.Number = 2501 Then
Resume Next
Else
Resume Next
End If
I have tried lots of different variations of code, but can't seem to crack it.
Any advice is welcome.
Daz.....
I have the following forms setup:
frm_Main (Switchboard)
frm_Customers (Form)
frm_SalesDetailsSub (SubForm on frmCustomers showing basic details of items they have bought)
On frm_Main I can search for Customers by Surname using the following code behind a search button on the form:
On Error GoTo Err_Handler
Dim stQry
Dim stDocName As String
stQry = SearchSurname() 'Query containing tblCustomers
stDocName = "frm_Customers"
DoCmd.OpenForm stDocName, acNormal, stQry, "((([tbl_Customers].[Customer_LName])like[Customer Surname?]& ""*""))"
Err_Handler:
If Err.Number = 2501 Then
Resume Next
Else
Resume Next
End If
This works fine, however I also want to search by items on the subform frm_SalesDetailsSub by using another button on frm_Main. I have tried code like the one shown below.
On Error GoTo Err_Handler
Dim stQry
Dim stDocName As String
stQry = SearchSaleItem() 'Query containing tblCustomers and tblSales Items linked via ID
stDocName = "frm_Customers"
DoCmd.OpenForm stDocName, acNormal, stQry, "((([tbl_Sales_Details].[Sales_Details])like [Item Description?]& ""*""))"
Err_Handler:
If Err.Number = 2501 Then
Resume Next
Else
Resume Next
End If
I have tried lots of different variations of code, but can't seem to crack it.
Any advice is welcome.
Daz.....