how to save variable from Form "label" to table

R

RCGUA

I have a complicated access db, but to simplify the question I will
just describe the basic question. I have a form, the form is bound
to a table, the form contains only one thing, a label. When you click
on the label a variable is generated, what the variable contains is
irrelevant. The question is, how can I save the variable data to the
table? Labels can't be bound to a table field, so I know this has to
be done in the code but I don't know the syntax to save it. To make
it easier to answer the question, let's say that every time the label
is clicked it is a new record in the table (if I can get it saved, I
can write some code to determine whether it is a new or updated
record).
 
D

Douglas J. Steele

If the form is bound to a table, you should be able to simply set the field
in the Click event:

Private Sub Label0_Click()

Me!NameOfField = value

End Sub
 
R

RCGUA

If the form is bound to a table, you should be able to simply set the field
in the Click event:

Private Sub Label0_Click()

  Me!NameOfField = value

End Sub

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)






- Show quoted text -

Thank You! that was quick and simple and clean. It works
perfectly.
I added: If Me.Dirty Then Me.Dirty = False
and that saves to the current record, now I will work on saving it as
a new record
 
D

Douglas J. Steele

Private Sub Label0_Click()

DoCmd.GoToRecord , , acNewRec
Me!NameOfField = value

End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


If the form is bound to a table, you should be able to simply set the
field
in the Click event:

Private Sub Label0_Click()

Me!NameOfField = value

End Sub

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)






- Show quoted text -

Thank You! that was quick and simple and clean. It works
perfectly.
I added: If Me.Dirty Then Me.Dirty = False
and that saves to the current record, now I will work on saving it as
a new record
 

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