Access 2003 Form:  Sync Record with listbox selected item

Posted on 2010-01-11
Medium Priority
Last Modified: 2013-11-28
I need a form that shows 'all the record' in a list box and the selected value (if one) in the list box to be the active record in the form object boxes (see attached photo).  

What form record events can I invoke to set the record to be the selected record in the list box?  I'm drawing a blank here...
Question by:tc100years
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 26287046
you can use the afterupdate event of the listbox, to find the corresponding record or to filter the form

'to filter the form
private sub Listboxname_afterupdate()

me.filter="[Software]='" & me.listboxName & "'"

end sub
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 26287126
'find the corresponding record

private sub Listboxname_afterupdate()

with me.recordsetclone
     .findfirst "[Software]='" & me.listboxName & "'"
     if not .nomatch then me.bookmark=.bookmark
end with

end sub

if you are using recordID for both the form and the listbox, we will use them to find the record

post the rowsource of yuor listbox, boundcolumn

LVL 31

Accepted Solution

Helen Feddema earned 2000 total points
ID: 26287617
Here is a slightly simpler version that I use for a record selector combo box; it can be modified for use with a listbox.  Bear in mind that you need to use one or the other line of code for the search string, depending on whether the key field is numeric or text.
Private Sub cboSelect_AfterUpdate()
'Written by Helen Feddema 29-Jun-2009
'Last modified 11-Oct-2009

On Error GoTo ErrorHandler

   Dim strSearch As String

   'For text IDs
   strSearch = "[______ID] = " & Chr$(39) & Me![cboSelect].Value _
      & Chr$(39)

   'For numeric IDs
   strSearch = "[______ID] = " & Me![cboSelect].Value

   'Find the record that matches the control
   Me.Recordset.FindFirst strSearch

   Exit Sub

   MsgBox "Error No: " & Err.Number _
      & " in " & Me.ActiveControl.Name & " procedure; " _
      & "Description: " & Err.Description
   Resume ErrorHandlerExit

End Sub

Open in new window


Author Closing Comment

ID: 31675704

Thanks much!

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question