Results 1 to 5 of 5
  1. #1
    mar_t is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    52

    Identical record in a Listbox


    I have a form with a listbox (lstStaff) which contains staff names and a textbox (txtSearch) for searching. Using my txtSearch box, I was able to filter 2 records with identical Family names. I double click the first item in my listbox and it opens my form (frmStaff) with all the informations for that staff--OK, but when I double click the second item still displays informations from the first item.


    Help...

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    What exactly is the RowSource of the ListBox?

    Can you show us the code for your txtSearch box Events?

  3. #3
    mar_t is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    52
    Code for my txtSearch:
    Code:
    Private Sub txtSearch_Change()
    Me.lstStaff.Requery
    Me.Refresh
    Me.txtSearch.SelStart = Me.txtSearch.SelLength
    End Sub
    my Listbox RowSource:
    Code:
    SELECT tblStaff.LastName, tblStaff.FirstName, tblStaff.Number, tblStaff.Unit FROM tblStaff WHERE (((tblStaff.LastName) Like Forms!frmStaff!txtSearch & "*"));

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    Show the RecordSource the form is based on and the code that you use to filter the records. Need to refer to the unique staff Number field from the listbox item.

    Instead of a textbox and listbox, suggest a combobox with a RowSource of:
    SELECT [Number], LastName & ", " & FirstName As StaffName;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    Quote Originally Posted by mar_t View Post
    Code for my txtSearch:
    Code:
    Private Sub txtSearch_Change()
    Me.lstStaff.Requery
    Me.Refresh
    Me.txtSearch.SelStart = Me.txtSearch.SelLength
    End Sub
    my Listbox RowSource:
    Code:
    SELECT tblStaff.LastName, tblStaff.FirstName, tblStaff.Number, tblStaff.Unit FROM tblStaff WHERE (((tblStaff.LastName) Like Forms!frmStaff!txtSearch & "*"));
    I've made a small mock up of your situation. Hopefully it shows the concepts.
    You didn't show code for the DoubleClick event for an item in the Listbox.
    I wasn't sure of the name of your form with txtSearch and LstStaff, but I have 2 forms; frmStaff and frmStaffDetails.

    Post with questions as necessary.
    Good luck.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-15-2011, 03:53 PM
  2. Navigate to a record in a listbox
    By jackkent in forum Access
    Replies: 4
    Last Post: 10-03-2010, 09:36 AM
  3. Count number of identical posts
    By Patience in forum Access
    Replies: 1
    Last Post: 06-16-2010, 04:27 AM
  4. Difference between 2 identical tables.
    By leepan2008 in forum Access
    Replies: 1
    Last Post: 09-28-2009, 07:36 PM
  5. Validation on identical text question
    By edrahl in forum Database Design
    Replies: 1
    Last Post: 02-26-2008, 09:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums