Leventcos21
Technical User
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
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