Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Navigation Buttons & Listbox Sync'ing

Status
Not open for further replies.

DavidWill

Technical User
Jan 2, 2002
8
US
Hi,

I am a beginner at Access 2000 and I have a question to ask. At the top of my form is a listbox with all the records for that form. I used the lookup wizard to create the listbox as a way to navigate between records. The listbox works fine, when I select a record in the listbox the form displays the record. However when I use the navigation buttons on the bottom of the form it doesn't keep the listbox selection in sync. Is there a way to have the navigation buttons keep my lookup listbox in sync with one another?
 
There is always a way. The question is are you willing to put in the necessary effort to implement it. It is somewhat confusing what you mean by InSych because listboxes aren't normally used the was you are trying to use them and there is. I think what you are asking is if the user navigates using the navigation buttons on the bottom of the form then the listbox still shows a selected record which is no longer being displayed. Do you want to:

1) Status Quo and remove ambiguity
Remove the navigation buttons from the form and force the user to use only the listbox for navigation. The problem goes away. If there are few records I would suggest this option.

2) Change the listbox item selected each time the user moves to another record.
In the OnCurrent event you would need to write the code to a) finds the key field(s) you represent in the listbox for the current record, b) find the key field(s) for the current record in the listbox, c) select the key field(s) in the listbox using code.

Your choice.

Steve King

Growth follows a healthy professional curiosity
 
Steve,

Yes, option 1 would work. But the users are used to using navigation buttons for another application. As a last resort I will use option 1.

I would like to try option 2. I know how to get the current record for the form, but how do you go to that record in the listbox? (Recordset possibly)
 
From memory only,


Sub Form_OnCurrent

Dim intCtr As Integer
Dim strValue As String

strValueToLookForInTheListbox As String
strValueToLookForInTheListbox = Me.ControlName

For intCtr = 0 To MyListbox.ListCount - 1
If MyListbox.ItemData(intCtr) = strValueToLookForInTheListbox Then
MyListbox.ItemData(intCtr).Selected = True
End If
Next intCtr

End Sub

Steve King

Growth follows a healthy professional curiosity
 
I'm using A97 and also needed to show the user the numbers of record in the listbox. Since Mr David were using A2K, can I use the code which you have written on for him?
 
Try it. That is the optimal test. I don't see why not.

-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top