copying a value to a new record in a subform

P

Paul

I need to write some VBA code that will copy a text value into a text field
in a new record in a subform.

That subform text field is given by:

forms![frmActivity]![ctlActivitySub].Form![Status]

How can I write the assignment statement so the text will be entered in the
Status field of a new record in the subform?

Thanks in advance,

Paul
 
N

NetworkTrade

you are practically there; but don't say where this text is coming
from......presuming it is coming from a text field on the main form (i.e
Me.TextField) then you would put this in the AfterUpdate Event of the
Me.TextField property:

forms![frmActivity]![ctlActivitySub].Form![Status]=me.TextField

can be abbreviated to:
me.[ctlActivitySub].Form![Status]=me.TextField
 
P

Paul

Thanks for the reply, NTC. However, I neglected to mention that the subform
containing the target field is a continuous form, and a straight assignment
as you listed below will in general copy the value into the last record
created in the subform. The exception to this is that if you select one of
the earlier records in the subform prior to running the code, the assignment
statement will copy the value into that record you selected, rather than
into the last existing record.

What I need is to have the VBA procedure copy the value into the Status
field of a NEW record in that subform. Any idea on how I can get it to only
copy the value into a new record?

Thanks



NetworkTrade said:
you are practically there; but don't say where this text is coming
from......presuming it is coming from a text field on the main form (i.e
Me.TextField) then you would put this in the AfterUpdate Event of the
Me.TextField property:

forms![frmActivity]![ctlActivitySub].Form![Status]=me.TextField

can be abbreviated to:
me.[ctlActivitySub].Form![Status]=me.TextField

--
NTC


Paul said:
I need to write some VBA code that will copy a text value into a text
field
in a new record in a subform.

That subform text field is given by:

forms![frmActivity]![ctlActivitySub].Form![Status]

How can I write the assignment statement so the text will be entered in
the
Status field of a new record in the subform?

Thanks in advance,

Paul
 
N

NetworkTrade

one way would be to build/trigger an AppendQuery

and then refresh the form
--
NTC


Paul said:
Thanks for the reply, NTC. However, I neglected to mention that the subform
containing the target field is a continuous form, and a straight assignment
as you listed below will in general copy the value into the last record
created in the subform. The exception to this is that if you select one of
the earlier records in the subform prior to running the code, the assignment
statement will copy the value into that record you selected, rather than
into the last existing record.

What I need is to have the VBA procedure copy the value into the Status
field of a NEW record in that subform. Any idea on how I can get it to only
copy the value into a new record?

Thanks



NetworkTrade said:
you are practically there; but don't say where this text is coming
from......presuming it is coming from a text field on the main form (i.e
Me.TextField) then you would put this in the AfterUpdate Event of the
Me.TextField property:

forms![frmActivity]![ctlActivitySub].Form![Status]=me.TextField

can be abbreviated to:
me.[ctlActivitySub].Form![Status]=me.TextField

--
NTC


Paul said:
I need to write some VBA code that will copy a text value into a text
field
in a new record in a subform.

That subform text field is given by:

forms![frmActivity]![ctlActivitySub].Form![Status]

How can I write the assignment statement so the text will be entered in
the
Status field of a new record in the subform?

Thanks in advance,

Paul
 
P

Paul

build/trigger an AppendQuery and then refresh the form

Ah! That's it.

Thanks, NTC.

Paul
 

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