Repeat data from previous records in a form

S

sjf

I am creating a a form for data entry and want to know if there is a way to
repeat data in fields from the previous record (or default to previous
record). For example, I user has 100 entries - I would like to set up the
form so they do not have to enter their ID each time they enter a record.
 
P

Paul Sanguinetti

When you hold the ctrl key and click the apostrophe key ' access copies the
contents of the same field from the previous record. This assumes that the
new record immediately follows the old record so you may have to sort the
source table and requery it after each time a new record is inserted. If you
are entering all 100 records one right after the other and the key is
sequential you shouldn't have to sort it.
 
L

Linq Adams via AccessMonster.com

Sure, you just set the DefaultValue for the field in the field's AfterUpdate
event!
After a value is entered, in your date field, for instance, it will
automatically be entered in each new record thereafter until you change it
(in which case the new entry will become the default value) or you close down
the form

The syntax is slightly different, depending on the datatype.


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

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
S

sjf

That is what I am looking for. I've was able to get the "CTR + Apostrophe
(") to work but it only works for 1 record at a time and you have to keep
doing it for each 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