I Need VBA Assistance on record auto update

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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
 
Back
Top