Link to home
Start Free TrialLog in
Avatar of SpaceCoastLife
SpaceCoastLife

asked on

MS Access 2013 Subform Search

As the title implies, I have a main form and a subform i.e frmMain, frmMain_sf with a Combo Box  on the frmMain listing all of the records listed in frmMain_sf. The record source for the subform is a stored query with no record source for frmMain.

I want to select a value in the Combo Box and go to that record on the subform.  I would also like to highlight the record found in some manor i.e. different row color.

Help anyone?
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

To go to your selected record, add something like this in your combo box's AfterUpdate event:
    With Me.frmMain_sf.Form.RecordsetClone
        .FindFirst "[UniqueKeyField] = '" & Me.cmbNameOfComboBox & "'"
        If Not .NoMatch Then
            Me.frmMain_sf.Form.Bookmark = .Bookmark
        End If
    End With

Open in new window


If the UniqueKeyField in is a Numeric data type, change the FindFirst line to this instead:
.FindFirst "[UniqueKeyField] = " & Me.cmbNameOfComboBox

Ron
ASKER CERTIFIED SOLUTION
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SpaceCoastLife
SpaceCoastLife

ASKER

Search works great. Is there a way to change the row color of the selected row?
Did you miss my second posting?
I did, sorry.  Let me check it out
Pretty clever! Thanks for the help.
Your welcome.