I Need VBA Assistance on record auto update

G

Guest

Good morning,

I am making an Access VBA module and need assistance. I made a table to
contain a single record and I need to know if there is a way first to assisgn
this record to get its value from a text box on a form entered by a userAnd
then to use VBA to make this record automatically update its value anytime a
user types another value in this text box and clicks on UPDATE button? My
table name is CURRENT_YEAR and my form name is CURR_YEAR.Any suggestions?
Thanks.
 
M

Marshall Barton

Brent said:
I am making an Access VBA module and need assistance. I made a table to
contain a single record and I need to know if there is a way first to assisgn
this record to get its value from a text box on a form entered by a userAnd
then to use VBA to make this record automatically update its value anytime a
user types another value in this text box and clicks on UPDATE button? My
table name is CURRENT_YEAR and my form name is CURR_YEAR.Any suggestions?


What is the purpose of the form?

If it's just to let the user specify the CurrYear then bind
the form to the table (with AllowAdditions set to No).

If the form has some other purpose and you want to track the
last value for CurrYear, then use the form's Load event to
retreive the value from the table and put it in the text
box:
Me.thetextbox = DLookup("CurrYear", "CURRENT_YEAR")

The code behind your update command button would have to
save the value in the text box back to the table:
CurrentDb.Execute "UPDATE CURRENT_YEAR " _
& "Set CurrYear = " & Me.thetextbox
 

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