Auto repeat Previous Value in Fields

P

pervez

Hi
I need your help that how I get the previous Values in New Record Auto
basis, I have to repeat the previous 3 to 4 values in the forms again and
again. How It appears in the next record so that I keep my cursor on the
relevant field and rest of the information I can enter. Some time I have to
repeat many time as the value of the First 3 or more fields remain same
 
K

Klatuu

In each control where you want to repeat the current value for the next
field, make the Default Value property = the current value of the control.
You do this in the After Update event:

Me.txtSomeControl.DefaultValue = Me.txtSomeControl

Then to position the cursor in the first control that you want to enter data
for, use the form Current event. Test to see if it is a new record. If it
is, set the focust to that control

If Me.NewRecord Then
Me.txtFirstControl.Setfocus
End if

Of course, the names are made up. Use your own.
 
K

Ken Sheridan

I'd add one thing to what Dave has said.

The DefaultValue property is always a string expression, regardless of the
data type, so should be wrapped in quotes characters like so:

Me.txtSomeControl.DefaultValue = """" & Me.txtSomeControl & """"

A lot of the time it won't matter if the quotes are omitted, but sometimes
they can be essential, so its prudent to always use them. Dates are a case
where it is particularly important as a date in short date format in a
control can otherwise be interpreted as an arithmetical expression and give
the wrong date. BTW don't think you can safely use the # date delimiter
character instead of quotes when setting a default date value. As literal
date values delimited by the # sign must be in US short date or otherwise
internationally unambiguous format this will insert the wrong date on systems
using other international date formats unless the date in the non-US format
happens to be an invalid date in US format.

Ken Sheridan
Stafford, England
 
D

Dale Fye

Pervez,

Are you attempting to enter the data in a form, or directly in a table?

If in a form, Dave and Ken's responses make sense. I don't believe you can
do what you are asking to do directly in a table.

HTH
Dale
 
A

Alex W

I've attempted this method, and although I can tell it is working by keeping
an eye on the entry next to "Default value" in the "Properties" box when
entering data, new records do not actually get that value entered into the
field! (I.e. the field is still blank.)

Any ideas why? I'm using this in a subform, which is displayed as a table
(i.e. columns, with each record being a separate row).
 

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