ADO - Field Names (Collection)

T

TheDarkman

Hi,

I am working with a number of value tables that I would
like a user to be able to view & edit via a subform.
Basically the user selects the table from a combo box and
this changes the source value of my sub form to open the
correct data table (actually I store the data in
a "temporary" table so the data isn't bound).

Once the user has finished editing the data and wants to
save I would like to minimise the code required to save
the changes.

To do this I would like to

1) Open the appropriate recordset

2) Loop through the recordset field names

Ok so as an example if I have two tables:

tblOne

- fldOne
- fldTwo
- fldThree

tblTwo

- fldOne
- fldTwo

and the temporary table:

tblTemp

- fldOne
- fldTwo
- fldThree

When saving the changes I only want to have one piece of
code something like:

for each fld in openrecordset
openrecordset.fld = temprecordset.fld
next

So if there is only two fields in the table it only picks
up the data from the first two fields in the temporary
table etc.

I'm using Access 2000 and ADO 2.5.

Any suggestions?
 
D

D. A. Gray

I think you are on the right track.

for each fld in openrecordset
openrecordset.fld = temprecordset.fld
next

dim Fld as Field
dim intJ as Integer

J = 0
for each Fld in openrecordset
Fld.Value = temprecordset.fields(J)
J = J + 1
next Fld

That should do it.

Kind regards,
David Gray
P6 Consulting
http://www.p6c.com/
 

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