Update a field(Column) in a listbox?

  • Thread starter Thread starter Jack
  • Start date Start date
J

Jack

Using Access2000
Is there any way to update/change a field in a listbox when the row is
selected.
I have a multi column list box. One of the columns needs to be changed when
the row is slected.
i.e. NAME Address CODE etc...

I would like the CODE field Contents to be changed from "A" to "B" for the
row that would be selected.

I can't seem to figure out a way to do this.
Is it possible?
Thanks
 
Jack

This is very possible. The problem in explaining how to do this is I need mor info, but here'goes

1> If your listbox contains a "static" list; if your listbox is not bound to a table/fields = you simply add code like this: For each listitem in the lisbox list :: If the list item is selected then change the column "CODE" to whatever value you want, otherwise the value should be whatever a non-selected item should be. (Obviously, this is a PSEUDO code example.

2> There are many different object classes packaged with Office, therefore the type of listbox would determine how the actual code might be written

Hoe this helps
Jason
 
The list box is based on a query. The query has a field with a criteria
based on a sub form so that when the subform record is selected the List box
gets filled based on the Query. Once the List box is filled I want to be
able to select a row & have that rows column 4 (for example) change to
something. I am attempting this via VBA but can't seem to get it.
I know how to reference a column and a row to GET or display the Info in a
particular Column,Row, but I can't figure out How to update or change that
particular row,column, when it is selected.
If you need more details, please let me know.



Jason said:
Jack,

This is very possible. The problem in explaining how to do this is I need mor info, but here'goes:

1> If your listbox contains a "static" list; if your listbox is not bound
to a table/fields = you simply add code like this: For each listitem in the
lisbox list :: If the list item is selected then change the column "CODE" to
whatever value you want, otherwise the value should be whatever a
non-selected item should be. (Obviously, this is a PSEUDO code example.)
2> There are many different object classes packaged with Office, therefore
the type of listbox would determine how the actual code might be written.
 
You would have to use code to change the value in the row source's
recordset. Next, you would have to set a variable to remember which row(s)
you had selected then requery the listbox. After the requery, have the code
reselect the rows you had selected. You would do this in the Click or After
Updated event of the listbox. What are you trying to accomplish, there may
be a better way?
 
Back
Top