Save field value for auto insertion into new record field

D

Derek

Hi

I need is a way to save the value in one current record
field and insert it into a different field on a new record
automatically. It would be nice to be able to reverse this
so if the new record is not subsequently used, this would
save a lot of new records being created when the "start
new record" button is pressed accidentaly. I am not sure
if a value inserted in a field by code automatically
creates a new permanent record.
 
S

SA

Derek:

If you set a field to a value in code while on a new record e.g.
Me!CompanyID = 12345, then yes it does automatically start a new record in
the db. The record isn't saved until you move off of it or save it directly
but if you want to avoid the possibility of incomplete records being saved,
then rather than setting a control directly to the value, set the control's
default value to the value from the previous record (captured in the after
update event of the old record and set in the on current event of the new
record if Me.newrecord = True) e.g. Me!CompanyID.DefaultValue = "12345"
 
D

Derek

Thats brilliant gents. You may have given me a clue to the
cause of another problem. When I enter a new record in a
subform when the main form is also a new record when I
press print to print the new record (an invoive for
example) I always get an error on the printout. No mater
how many times I refreh the record it will not print until
I close and re-open the form and reselect the relative
record. It's as if the dambed record isn't there or
perhaps as you put it isn't dirty yet. How do I overcome
this?



-----Original Message-----
Derek:

If you set a field to a value in code while on a new record e.g.
Me!CompanyID = 12345, then yes it does automatically start a new record in
the db. The record isn't saved until you move off of it or save it directly
but if you want to avoid the possibility of incomplete records being saved,
then rather than setting a control directly to the value, set the control's
default value to the value from the previous record (captured in the after
update event of the old record and set in the on current event of the new
record if Me.newrecord = True) e.g. Me!
CompanyID.DefaultValue = "12345"
 
Top