Hi,
I have a search function attached to a list
This opens the form at the correct record - However - What I would like to do is to apply a filter so that only that record is chosen - No other records should be available to it - the only way to view another record would be to go back to the search box.
I have no idea where to apply the filter - but would have thought it would be in the code above?
cheers
I have a search function attached to a list
Code:
Private Sub QuickSearch_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Dim stDocName As String
Dim cType As String
Dim claimsID As Integer
Dim strSQL As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
claimsID = CInt(Nz(Me![QuickSearch], 0))
Set db = CurrentDb()
strSQL = "SELECT tblClaims.[claimLossRepair] FROM tblClaims WHERE tblClaims.[claimID]= " & CInt(Nz(Me![QuickSearch], 0)) & ""
Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)
cType = rst!claimLossRepair
Set rst = Nothing
Set db = Nothing
If cType = 1 Then
DoCmd.OpenForm "frmClaimsSalvage", acNormal, , "claimID=" & CInt(Nz(Me![QuickSearch], 0))
If CurrentProject.AllForms("frmMasterSearch").IsLoaded Then
DoCmd.Close acForm, "frmMasterSearch", acSaveYes
End If
Else
DoCmd.OpenForm "frmClaimsParts", acNormal, , "claimID=" & CInt(Nz(Me![QuickSearch], 0))
If CurrentProject.AllForms("frmMasterSearch").IsLoaded Then
DoCmd.Close acForm, "frmMasterSearch", acSaveYes
End If
End If
End Sub
This opens the form at the correct record - However - What I would like to do is to apply a filter so that only that record is chosen - No other records should be available to it - the only way to view another record would be to go back to the search box.
I have no idea where to apply the filter - but would have thought it would be in the code above?
cheers