Filtering A Form

MrRundog

Happy User
Local time
Today, 03:55
Joined
Mar 8, 2008
Messages
44
Hi,

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
 
Ok - Actually - This does open up the correct ID - and only that ID - But - If I place a Preview report button - linked to a report - I am getting all records in the report - How can I make this not so?

Cheers
 

Users who are viewing this thread

Back
Top Bottom