search subform

sambucaman

Registered User.
Local time
Today, 02:47
Joined
May 6, 2010
Messages
41
Hi guys

I have a form, with the following code on

Code:
Private Sub searchName_AfterUpdate()
    Dim LSQL  As String
    Dim LSearchString As String
    
    If Len(searchName) = 0 Or IsNull(searchName) = True Then
        MsgBox "You must enter a search string!"
        
    Else
    
        LSearchString = searchName
        
        'Filter results based on search string
        LSQL = "select * from Customers"
        LSQL = LSQL & " where Name LIKE '*" & LSearchString & "*'"
       
        
        Form_Customers.RecordSource = LSQL
       
        'Clear search string
        searchName = ""
        
        'MsgBox "Results.  All customers containing " & LSearchString & "."
        
    End If
End Sub

Private Sub searchName_BeforeUpdate(Cancel As Integer)

End Sub

This works very well for searching through my customers, and returns results within the same form. However, I have a subform on the form, called "OrderHistory" which is just a simple table with orderdate, ordernumber, orderamount, ect.

Is there anyway to modify the above code to search the table "OrderHistory" for the field "OrderNumber" and display the results in the same way as above?

I have tried to jiggle the above, but to no avail...

Thanks in advance!
 
If the tables are related for example, customerid with a related customerid in the orders table.

I would expect to see a relation as all orders should have a related customer. You would rarely see an order with no related customer.

If the links exist, then the results should show customers and their orders.

Hope this helps.

Steve
 

Users who are viewing this thread

Back
Top Bottom