We help IT Professionals succeed at work.

MS Access 2013 Subform Search

SpaceCoastLife
SpaceCoastLife asked
on
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?
Comment
Watch Question

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
To highlight a record, you can use Conditional Formatting.  Set the rule for a textbox in your continuous form to:
Expression Is and [UniqueKeyFIeld] = Parent.[cmbNameOfComboBox], and select your highlight color.

Then add this line to your combo box's AfterUpdate Event:
Me.frmMain_sf.Form.Refresh

If you want to highlight a whole row, then use an unbound textbox for your conditional formatting and make it span the whole row, put it behind all the other textboxes and change the background properties of the other textboxes to Transparent.

Ron

Author

Commented:
Search works great. Is there a way to change the row color of the selected row?
Did you miss my second posting?

Author

Commented:
I did, sorry.  Let me check it out

Author

Commented:
Pretty clever! Thanks for the help.
Your welcome.