I have this code on a popup form. The user selects from the Combo2 then clicks find. This code works but it returns all records having data in either CatCode or CatCode2 fields or my Main form. I want it to search those 2 fields and return only records that match the value of Combo2 on my popup form. Not any value...
Code:
Private Sub FindRecords_Click()
On Error GoTo Err_Command3_Click
Dim flt As String
Dim rs As DAO.Recordset
Dim lRecordCount As Long
flt = "[CatCODE] Or [CatCode2] = '" & Me.Combo2 & "'"
DoCmd.Close
DoCmd.OpenForm "frmMainData", acNormal, , flt, acFormEdit
Debug.Print flt
Set rs = Forms!frmMainData.RecordsetClone
If Not (rs.EOF) Then
rs.MoveLast
End If
lRecordCount = rs.RecordCount
If lRecordCount > 1 Then
MsgBox lRecordCount & " records found with that Code, Please make sure your viewing the correct record!" & vbCr & vbCr & _
"To do so, use the navigation buttons located at the bottom left of the form. "
End If
Set rs = Nothing
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
Last edited: