In VBA get or set a field value in an access table

A

ari

Hello

Can anyone tell me how to get or set a field value in an access table thru VBA code

Thanks in advance
ari
 
D

Dirk Goldgar

ari said:
Hello,

Can anyone tell me how to get or set a field value in an access table
thru VBA code?

Thanks in advance,
ari

There are several ways to to do this. To get a field value you can open
a recordset on a query of the table using DAO or ADO, or (simpler though
often less efficient) you can use the DLookup function to extract the
field value. Either way, if there's more than one record in the table,
you need to be able to specify criteria -- a key-field value, for
example -- that identifies the specific record you want to get the value
from.

To set a field value, you can open a recordset on a query that extracts
the record you want, update the field in the recordset, and close the
recordset. Or, what is usually more efficient, you can execute an
update query that identifies the record (or records) to be updated sets
the field value in that record. To execute this query you can use
DoCmd.RunSQL or the DAO Execute method. Again, you need to be able to
identify the specific record or records to be updated by supplying a
WHERE clause to the query.
 

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