Repeat field value in next field

S

sharontodd

This has to be super easy, but I have searched the forum and Help and can't
find it. I want the value from a field in the previous record to be repeated
in the next field so that the user doesn't have to retype it as long as that
value doesn't change.

For example, in a form that accepts the names and numbers to be screen
printed, the type of garment and the color have to be entered. These will
normally repeat for every line in the record. I would like the user to be
able to enter that in the first record and have it automatically repeat in
each following record, with the option to type a new value and then have
that value repeated.

Thanks for your help.

Sharon
 
F

fredg

This has to be super easy, but I have searched the forum and Help and can't
find it. I want the value from a field in the previous record to be repeated
in the next field so that the user doesn't have to retype it as long as that
value doesn't change.

For example, in a form that accepts the names and numbers to be screen
printed, the type of garment and the color have to be entered. These will
normally repeat for every line in the record. I would like the user to be
able to enter that in the first record and have it automatically repeat in
each following record, with the option to type a new value and then have
that value repeated.

Thanks for your help.

Sharon

This is for new record entry?
Set the default value property of the control in the Control's
AfterUpdate event:

For each control on your form that you wish to carry over to the next
new record .....
If the field is NOT a Date datatype, code that control's AfterUpdate
event:

Me![ControlName].DefaultValue = """" & Me![ControlName] & """"

If the field is a Date datatype, then code that control's AfterUpdate
event:

Me![DateField].DefaultValue = "#" & Me![DateField] & "#"

You'll have to enter the value just once per session.
It will remain the same for each new record until changed.
 
J

Jack Leach

Create a variable private to your form's module and use the Current event of
the form to set the value of the control when you change record. You can use
the AfterUpdate event of the control to carry the value from in order to set
it at a new value... something like this (air code)


Option Compare Database
Option Explicit

Private pstrGarmentColor As String

Private Sub Form_Current()
If Len(Nz(pstrGarmentColor, "")) <> 0 Then
Me.yourcontrol = pstrGarmentColor
End If
End Sub

Private YourControl_AfterUpdate()
If Len(Nz(Me.yourcontrol, "")) <> 0 Then
pstrGarmentColor = Me.yourcontrol
End If
End Sub



something along those lines anyway... the private variable declared at
module level will exist from the time the form opens until it closes (or if
the code is reset through debugging or nonexistent error handler). You may
have to play around with a few events to get what you want but the basic idea
is there.

hth

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 

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