listbox

  • Thread starter Thread starter ChoonBoy
  • Start date Start date
C

ChoonBoy

I have a listbox in my Form. When I navigate to other records using the
Form's navigator the listbox does not corresponds to the record. How do I
make it to corresponds accordingly.

Thanks in advance
 
ChoonBoy,
Use the OnCurrent event of the form to Requery your listbox. As you
browse to each record, the Requery will "re-synch" the listbox according to
some value on that particular record.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
Al,

Thanks, but it still doesn't work for my form

me!lstSelect.requery

is the code I used in the Form's on current.

When I select using the listbox, the Form's navigation will synch with the
record. However when I navigate using the navigator, the listbox remained in
its last selection.

Thanks in advance.

Regards
 
"When I select using the listbox, the Form's navigation will synch with the
record. However when I navigate using the navigator, the listbox remained in
its last selection."

If you're using the listbox for navigation purposes, it has to be unbound.
This is reinforced by your statement "when I navigate using the navigator,
the listbox remained in its last selection." This is the normal behavior for
an unbound control on a form. For it to show the value that was selected for
a given record, on the other hand, it would have to be bound to a field on
the underlying table. You can't really have it both ways.
 
ChoonBoy,
Please cut and paste the entire code (procedure) you used in your next
reply.

Is the combobox "bound" to a field, or is it "unbound?"

*Upon re-reading your initial post*, I'm wondering if you're using this
"unbound" listbox to select a value, and use that value to locate a specific
record.
If that's true...
what is the value you are selecting in the listbox, and why is it necessary
that the listbox synch to the record you navigate to.
On my website, I have a 97 and 2003 sample file called Quick Find Combo
(combo would work the same as a listbox in this regard)
User selects a name from a combo, and that record is located. But, when
you manually navigate off that "found" record, the combo value (from the
last find) is still there. That's not a problem... that's how an "unbound"
field works. Whatever value is in the listbox, that value will remain...
until changed.

Let's say you select a CustomerID from the listbox, and find that
CustomerID record.

You could either...
1. Use the OnCurrent to manually force the listbox to show that's
records value.
Private Sub Form_Current()
Me.lstSelect = Me.CustomerID
End Sub
2. OnCurrent to Set the listbox to Null
Private Sub Form_Current()
Me.lstSelect = Null
End Sub
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
Al,

Your assumption is correct. The code you provided does exactly what I wanted.

Thanks & regards
 
Back
Top