listbox problems

C

Chad

On a form that is bound to a query I have a listbox and
two checkboxes. The listbox contains 2 columns, column(0)
displays one field while column(1) displays another. The
checkboxes are updated depending on which record you
choose from the listbox.

For this example I will call the field displayed in column
(0) field1 and the field in column(1) field2.

Here is my problem, the checkboxes that I have are not
updated when I select different records in the listbox.
The weird thing is, the only way I can get them to update
is if I switch which fields are in which column (field2 is
in column(0) and field1 is in column(2)). Can anyone
think of what can be causing this? I would really like to
keep the origional format of the contents in my list box.

Thanks for any help you can give,
Chad
 
J

John Vinson

Here is my problem, the checkboxes that I have are not
updated when I select different records in the listbox.

They wouldn't unless you Requery the checkbox controls in the
AfterUpdate event of the listbox.
 
C

Chad

John,
It still doesn't work even when I requery the checkboxes
in the After Update event tof the list box. Like I said
in my previous post. Everything works great if I change
the order of the columns (Putting filed2 in column(0) and
field 1 in column(1)), but I really don't want to have to
do that. Can you think of anything else it could be?

Thanks again,
Chad
-----Original Message-----
 
J

John Vinson

Its not just the checkboxes wouldn't requery. When I
click on different records in the listbox, the recordset
on the form never changes. (It always stays on the same
record) If I use the navigation buttons it will go to
the next record but not by selecting another record in
the listbox.

Selecting a record in a listbox will not, by itself, affect anything
else on the form. Could you post the VBA code that you're running in
the listbox's BeforeUpdate and AfterUpdate events?
 
J

John Vinson

Like I said, the above code works fine, but when I change
the order of the columns in the list box the code looks
like this (but doesn't work)

Private Sub lstCCResults_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[County] = '" & Me![lstCCResults] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

When you switched the order of the columns, did you also switch the
Bound Column? The code will take the value of the Bound Column
(whether that's the first or the second column) and search the County
field for that value.
 
C

Chad

John, can you please tell me how to change the bound
column in the list box?

Thanks,
Chad
-----Original Message-----
Like I said, the above code works fine, but when I change
the order of the columns in the list box the code looks
like this (but doesn't work)

Private Sub lstCCResults_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[County] = '" & Me![lstCCResults] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

When you switched the order of the columns, did you also switch the
Bound Column? The code will take the value of the Bound Column
(whether that's the first or the second column) and search the County
field for that value.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top