Link to home
Create AccountLog in
Avatar of military donut
military donutFlag for United States of America

asked on

Better Search Form

Been trying to improve upon my search form and well, I have a sample here but can't get it working correctly

I have the main form with 2 subforms

The main form has the search criteria, the first subform is in Datasheet view.  The apply filter applies it to the datasheet subform.  I have it set that if you select the record and double click it should open that record in the 2nd subform.

That is where the issue is.  I can't get it to do it.  When you doubleclick the "very first record" it opens it just fine.  Any other record, it doesn't.

Not sure where I am wrong.  I am posting that dB here.
TestDB.accdb
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

from my iPad,

can you post just the code from your double click event?
Avatar of military donut

ASKER

Sure...


Forms!frmReportFilter5!frm2.Form.Requery
This is the code from the Apply Filter

Private Sub cmdApplyFilter_Click()
    Dim strFirstName As String
    Dim strLastName As String
    Dim strFilter As String

' Build First Name criteria string
    If IsNull(Me.txtFirstName.Value) Then
        strFirstName = "Like '*'"
    Else
        Select Case Me.fraFirstName.Value
            Case 1
                strFirstName = "Like '" & Me.txtFirstName.Value & "*'"
            Case 2
                strFirstName = "Like '*" & Me.txtFirstName.Value & "*'"
            Case 3
                strFirstName = "Like '*" & Me.txtFirstName.Value & "'"
            Case 4
                strFirstName = "= '" & Me.txtFirstName.Value & "'"
        End Select
    End If
' Build Last Name criteria string
    If IsNull(Me.txtLastName.Value) Then
        strLastName = "Like '*'"
    Else
        Select Case Me.fraLastName.Value
            Case 1
                strLastName = "Like '" & Me.txtLastName.Value & "*'"
            Case 2
                strLastName = "Like '*" & Me.txtLastName.Value & "*'"
            Case 3
                strLastName = "Like '*" & Me.txtLastName.Value & "'"
            Case 4
                strLastName = "= '" & Me.txtLastName.Value & "'"
        End Select
    End If
' Build filter string
    strFilter = "[FirstName] " & strFirstName & _
                " AND [LastName] " & strLastName
' Apply filter to form
        
        Me.frm.Form.Filter = strFilter
        Me.frm.Form.FilterOn = True
       
      
       
   
End Sub

Open in new window

Avatar of crystal (strive4peace)
crystal (strive4peace)

Ernest, I see Dale is helping so you are in good hands ~ Requery sets the record back to 1 -- use Bookmark to save position and set it back after requery

Dale, Ernest was using a split form and, in another thread, I suggested a regular form with unbound combos in the header and gave him filter code to customize
Thanks Crystal!
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
I know...it was just a sample...I didn't set it up but was working with primarily the coding Crystal was working with me on.

I have my DB that is right....but I think I got that to work properly by moving it to the ID in the form's record source.

just testing to make sure at this point.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.