Repeat data from previous records in a form

  • Follow


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.
0
Reply Utf 11/30/2007 5:10:01 PM

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.

"sjf" wrote:

> 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.
0
Reply Utf 11/30/2007 5:29:04 PM

Is there a way to do this so it will be automatic?
-- 
Thanks, Joy


"Paul Sanguinetti" wrote:

> 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.
> 
> "sjf" wrote:
> 
> > 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.
0
Reply Utf 11/30/2007 10:02:00 PM

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
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200711/1

0
Reply Linq 11/30/2007 10:32:21 PM

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.

"Joy" wrote:

> Is there a way to do this so it will be automatic?
> -- 
> Thanks, Joy
> 
> 
> "Paul Sanguinetti" wrote:
> 
> > 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.
> > 
> > "sjf" wrote:
> > 
> > > 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.
0
Reply Utf 12/3/2007 5:51:03 PM

Glad it helped!

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

Answers/posts based on Access 2000/2003

Message posted via http://www.accessmonster.com

0
Reply Linq 12/3/2007 9:11:43 PM

5 Replies
4250 Views

(page loaded in 0.061 seconds)


Reply: