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

Access 2003 Form: Sync Record with listbox selected item

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...
form-example.bmp
0
tc100years
Asked:
tc100years
  • 2
1 Solution
 
Rey Obrero (Capricorn1)Commented:
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 & "'"
me.filteron=true

end sub
0
 
Rey Obrero (Capricorn1)Commented:
'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



0
 
Helen FeddemaCommented:
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

ErrorHandlerExit:
   Exit Sub

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

End Sub

Open in new window

0
 
tc100yearsAuthor Commented:
AWESOME!  IT WORKED!

Thanks much!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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