Help with searching

R

Richard

I am working on a multi-user form / subform one to many relationship. Two
data tables, master table (tblWarehouse) primary key set to WarehouseID /
autonumber child table (tblPurchData) primary key set to PurchaseOrderID /
autonumber with a foreign key WarehouseID from the master table. I am using a
small popup form for searching, this is woking great with the master table
(tblWarehouse), but I also need to search the the child table (tblPurch).
Below is the code I am using for my search function.
************************************************************

Private Sub cmdSearch_Click()

If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
MsgBox "You must select a field to search."

ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "You must enter a search string."

Else

'Generate search criteria
GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"

'Filter Form1 based on search criteria
Form_ListFrm.RecordSource = "select * from tblWarehouse where " &
GCriteria
'Form_ListFrm.Caption = "tblWarehouse (" & cboSearchField.Value & "
contains '*" & txtSearchString & "*')"

'Close frmSearch
DoCmd.Close acForm, "frmSearch"
'Open report
DoCmd.OpenReport "rptWarehouse", acViewPreview, , GCriteria
DoCmd.Maximize

'MsgBox "Results have been filtered."

End If

End Sub
************************************************************

Can I add my child table before the "where" claus? or does it go on the
properties sheet of the popup form. Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top