Preautopopulate Form record

J

JaneM

How do I create a new record in a form copying (autopopulating) data from the
previous record? I already have created three forms. Would I have to redo
forms? Is this possible? Would I need to use code?
 
J

Jeff Boyce

Jane

You've described "how".

Now, "why?" What would having a new record that was an essential duplicate
of the previous record allow you to do?

(often when folks are trying to copy a previous record it is because they
are used to working in Excel rather than Access).

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
L

Linq Adams via AccessMonster.com

If, by "copying (autopopulating) data from the previous record" you mean can
you enter one record, move to a new record and have certain fields populated
with the same values from the previous record, yes you can and yes, it'll
require code.

In your form, you can use the AfterUpdate event of the control holding your
data to set the DefaultValue for the field. From that time forward, until you
either manually change the data or close your form, the data will be entered
automatically in each new record. The syntax varies slightly, depending on
the datatype of the data:

For Date fields

Private Sub YourDateControlName_AfterUpdate()
If Not IsNull(Me.YourDateControlName.Value) Then
YourDateControlName.DefaultValue ="#" & Me.YourDateControlName & "#"
End If
End Sub

For Text fields

Private Sub YourTextControlName_AfterUpdate()
If Not IsNull(Me.YourTextControlName.Value) Then
YourTextControlName.DefaultValue = """" & Me.YourTextControlName.Value &
""""
End If
End Sub

For Numeric fields

Private Sub YourNumericControlName_AfterUpdate()
If Not IsNull(Me.YourNumericControlName.Value) Then
YourNumericControlName.DefaultValue = Me.YourNumericControlName.Value
End If
End Sub
 
L

Linq Adams via AccessMonster.com

Your question is, of course, pertinent if the OP's intention is to carry
forward ***all*** data from the previous record, but not if he only wants to
carry forward certain fields. He doesn't really make this clear. People doing
"batch" data entries often find themselves entering ***some*** fields over
and over again, and can benefit from the technique I offered.

An example would be the weekly entering of delivery tickets, where the
operator might have to enter dozens of tickets for a given date, then move on
to another date and do the same.
 
J

Jeff Boyce

Yup, I've used the DefaultValue approach to carry values forward into new
records, and only for a limited number of controls.

Without more information, it's hard to offer more specific suggestions...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
L

Linq Adams via AccessMonster.com

True, Jeff! Just had a conversation elsewhere, today, noting that those of us
who answer questions on a regular basis spend at least 25-30% of our time not
***solving problems*** but rather trying to find out, from the OPs, ***what
the problem actually is***!
 
J

John W. Vinson

True, Jeff! Just had a conversation elsewhere, today, noting that those of us
who answer questions on a regular basis spend at least 25-30% of our time not
***solving problems*** but rather trying to find out, from the OPs, ***what
the problem actually is***!

In my experience, that applies in all areas of life, not just technical.
Correctly identifying the problem is not only essential - often, just (clearly
and correctly) stating the problem makes the solution obvious.

Reviewing some of the longer threads in these groups makes it clear that many
problems here don't get stated clearly... and indeed could be solved in
moments if they were!
 
Top