Results 1 to 7 of 7
  1. #1
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291

    how do I make a listbox update as I switch between records

    I have a listbox that displays the name of all the records, as I use the navigation buttons to go through different records my listbox does not update what it has selected. Any Ideas?

  2. #2
    SOS is offline Novice
    Windows 7 Access 2007
    Join Date
    Mar 2010
    Posts
    11
    Is your listbox bound to a field or is it unbound?

  3. #3
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291
    Unbound and here are some things you might want to know:

    Row Source:
    SELECT InspectionsDI.ID, InspectionsDI.[Manhole Number] FROM [InspectionsDI Query];

    Private Sub lstDI_AfterUpdate()
    DoCmd.GoToRecord acDataForm, "DropInletForm", acGoTo, lstDI.ListIndex + 1
    End Sub

    Thanks for help

  4. #4
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291
    I still cant figure this one out, when I hit the navigation button and go to the next record what procedures are called? a requery doesnt work so do I need to make a code to set the selection to a certain item?

  5. #5
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I will answer the question that you had asked in your first thread how to requery a List box while using the navigation buttons. I have attached a sample mdb as an example.

    I have attached the following code on the OnCurrent Event of the Form:
    DoCmd.Requery "List4"
    List4 is a List

  6. #6
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291
    I must be really bad at explaining what is going on.

    Ok so from the picture you can see that I have 359 records, in that list box I have the name of each record. When I click on a record it selects the name in black as shown with record 7 and pulls the correct information for the rest of the fields. In the second picture you can see I have clicked the navigate right button 5 times and am now on record 12. The information in all the fields and display image is correct. The only thing that doesnt update is it still has record 7 selected in the listbox.

    I tried this code under the code that is called from OnCurrent, it didnt work.
    Forms("DropInletForm")!lstDI.Selected(Forms("DropI nletForm")!lstDI.ListIndex) = True

    Any help is appreciated thanks.

  7. #7
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    What I understand from the latest screen shots that you have attached that you have a form which has about 359 records and a list box on it with the similar no.of records. Now What you want is:

    That as you navigate through the form the the it should have the same effect on the list box.

    So If you are on record two on the main form the item two will be selected in the list box.

    What I have done:

    Similar Set up I have a table called members in which I have the names of some the members of our forum. this is the record source of my form ListBoxUpdate this gives me a total record set of 8 (There are 7 names and one for a new record) now the list indexing of a list box starts from zero so the code that I have used is:

    Dim intCounter As Integer
    intCounter = Forms!ListBoxUpdate.CurrentRecord
    Me.List0.Selected(intCounter - 1) = True

    intCounter is counts the CurrentRecord and we use the selected property of the list box to select our records.When the Form opens the intcounter=1, thsu Me.List0.Selected(intCounter - 1) = True selects the 0 item on the list box which is the first item.

    If this solves your problem mark this thread solved. If you had posted the screen shots earlier it wold have been more helpful.

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

Similar Threads

  1. warning to make update note
    By ga3la in forum Access
    Replies: 1
    Last Post: 01-30-2010, 09:51 PM
  2. Loop through Records and Make ID
    By rob4465 in forum Programming
    Replies: 3
    Last Post: 01-14-2010, 10:46 AM
  3. How to Update 70,000++ Records
    By UCBFireCenter in forum Queries
    Replies: 54
    Last Post: 06-19-2009, 12:43 PM
  4. Multi-select listbox and update flag in table
    By Suresh in forum Programming
    Replies: 0
    Last Post: 12-19-2007, 01:04 AM
  5. Switch and Tables
    By UtilityRyan in forum Database Design
    Replies: 0
    Last Post: 06-12-2007, 03:49 PM

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