Taking a look at the query you are trying to use, it appears that both items
are in the same table. This means that they should have a one-to-one
relationship. That being the case, you don't need two listboxes and,
therefore, don't need to synchronize two listboxes. Set the Row Source of
just one listbox to
Select CardCode, CardName From Card_Data Order By CardCode;
Set the listbox's ColumnCount to 2 and set the column widths as needed to
fit the data. The BoundColumn would probably be one, which means that the
CardCode would be the value of the listbox when you make a selection (not
multiselect, if the listbox is multiselect, you have to step through all of
the selected items and get each individual value.) If you need to refer to
the CardName instead of the CardCode, you would use the listbox's Column
property.
Example:
strCardName = Me.Listbox.Column(1)
The Column property is zero based, so 0 is the first column, 1 the second,
etc.
If desired, you could create a button that would change the sort order and
requery the listbox in the button's Click event. The only difference in the
Row Source would be which field name appears after the Order By clause.
Example:
If Right(Me.Listbox.RowSource, 5) = "Code;" Then
Me.Listbox.RowSource = "Select CardCode, CardName From Card_Data Order
By CardName;"
Else
Me.Listbox.RowSource = "Select CardCode, CardName From Card_Data Order
By CardCode;"
End If
When you change the RowSource the listbox should automatically Requery. If
it doesn't, add the line
Me.Listbox.Requery
after each of the RowSource lines above.
--
Wayne Morgan
MS Access MVP
Rookie said:
In tryin to Base the value of a control on another control change, When a
user select the client code in "Code" listbox, the "Client" listbox must
show
the name of that client, and viceversa... The Access help dont shows an
example of this.
I try an OnChange event of Listbox "client", it it send a error:
Me!
Code:
= Select CardCode from Card_DATA Where CardName = Me![Client][/QUOTE]
[/QUOTE]