Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search a subform

Status
Not open for further replies.

Leventcos21

Technical User
Oct 7, 2004
77
US
Hi, I am trying to do a search on a subform by another form. I am trying to search a record by employees that is in a combobox. The subform has a M:M relationship. The following code isnot able to locat my mainform frmNCR. Any help would be greatly appreciated. Thank you

Private Sub cmdSearch_Click()
Dim varWhere As Variant

varWhere = Null


If Not IsNothing(Me.txtNCRNumber) Then

varWhere = "[NCRNumber] LIKE " & Me.txtNCRNumber & ""
End If


If Not IsNothing(Me.cboProcessOwner) Then
varWhere = varWhere & " AND " & [Forms]![frmNCR]![sfrmProcessOwner].ProcessID & " = " & Me.cboProcessOwner
End If



If IsNothing(varWhere) Then
Call CustomError("You must enter at least one search criteria.", , "NCR SELECTOR")
Exit Sub
End If

'DLookup
If IsNothing(DLookup("NcrNumber", "qryNCR", varWhere)) Then
msgbox("No NCR meet your criteria.", , "NCR SELECTOR")
Exit Sub
End If
txtNCRNumber.Value = Null
txtAssetname.Value = Null

DoCmd.OpenForm "frmNCR", WhereCondition:=varWhere
' Done
'DoCmd.Close acForm, Me.Name



End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top