• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 143
  • Last Modified:

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?
0
SpaceCoastLife
Asked:
SpaceCoastLife
  • 4
  • 3
1 Solution
 
IrogSintaCommented:
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
0
 
IrogSintaCommented:
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
0
 
SpaceCoastLifeAuthor Commented:
Search works great. Is there a way to change the row color of the selected row?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
IrogSintaCommented:
Did you miss my second posting?
0
 
SpaceCoastLifeAuthor Commented:
I did, sorry.  Let me check it out
0
 
SpaceCoastLifeAuthor Commented:
Pretty clever! Thanks for the help.
0
 
IrogSintaCommented:
Your welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now