On Click in a Form, assigning a value to a field in a record

N

Neal

Dear All,

I have a form with a Command button. What I would like to have happen is
when this command button is clicked, a value (i.e. 1) would be
input(assigned) into a field in a table. The code I have is as follows:

Private Sub Command0_Click()
Table!TaskEvaluator!EnvironKaizen.Value = 1
End Sub

TaskEvaluator is the table and EnvironKaizen is the field. I am getting an
error message. What is the correct code to do this? Thanks in advance.

Neal
 
T

tina

if the form is bound to table TaskEvaluator, or bound to a query based on
TaskEvaluator that includes field EnvironKaizen, then you can set the value
as

Me!EnvironKaizen = 1

even if the field is not bound to a control on the form.

but if table TaskEvaluator is not included in the form's RecordSource, then
you need to use an Append query to add the record to field EnvironKaizen, or
an Update query to change the value of field EnvironKaizen in an existing
record. or you can use a Recordset in VBA to open table TaskEvaluator and
add/update a record with the new value.

hth
 

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