changing value of field (notunique values) programmatically

G

george

Hi to all,

I have a table, tblTest, with two fields:

ID (primary key, type long)
Status (type byte, not unique values)

I also have a multiple selection list box, lstTest, with
two fields, based on the above mentioned table, tblTest.

I know how to change the ID field value for all selected
records in the list box through ado. Below is shown the
code I use:

dim cnn as Connection
dim rstTest as New ADODB.Recordset
dim varPosition as Variant

Set cnn = CurrentProject.Connection
rstTest.Open "tblTest", cnn, adOpenKeyset, _
adLockOptimistic, adCmdTableDirect

'Set the Index Property to search on the primary key.
rstTest.Index = "ID"

'Loop through each selected record in the list.
For Each varPosition In lstTest.ItemsSelected

'Find the record in the tblTest.
rstTest.Seek lstTest.ItemData(varPosition)

'Change the ID value in the table.
rstTest!ID = ...(NewID) 'Some variable with NewID
rstTest.Update

Next varPosition

This works fine. What I would like to know is how to
change the value of the second field of my table, Status,
(instead of the ID field) which doesn't contain unique
values. Can someone please modify the code in order to
accomplish this?

Thanks in advance, George.
 

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