Repeat Field Value

  • Thread starter Thread starter sharontodd
  • Start date Start date
S

sharontodd

I tried to post this earlier today, but it's not showing up when I do a
search so I'm trying again.

This has to be super easy but I can't find it in the forum or help. I am
trying to get certain fields to automatically fill in with the value from the
previous record. For instance, I have a form that inputs the details for
screen printing. There are fields for item and color, which typically are
the same for all or much of the record. After the user inputs values in the
first record, those values should automatically show up in the next field.
The user would be able to change them if they wanted.

Thanks for your help.

Sharontodd
 
I tried to post this earlier today, but it's not showing up when I do a
search so I'm trying again.

This has to be super easy but I can't find it in the forum or help. I am
trying to get certain fields to automatically fill in with the value from the
previous record. For instance, I have a form that inputs the details for
screen printing. There are fields for item and color, which typically are
the same for all or much of the record. After the user inputs values in the
first record, those values should automatically show up in the next field.
The user would be able to change them if they wanted.

Thanks for your help.

Sharontodd

You can make a field "sticky" in this way with just a little bit of VBA code.
In the textbox's AfterUpdate event set its DefaultValue property:

Private Sub txtColor_AfterUpdate()
Me!txtColor.DefaultValue = Chr(34) & Me!txtColor & Chr(34)
End Sub


Chr(34) is a " character, required as a string delimiter; the DefaultValue is
a string regardless of the datatype of the field.
 
Hi Sharon,

Have a look at the following link. I don't think that you will be able to
use the methods exactly as shown because you won't be able to overwrite them.
However, it should give you a pointer as to how to code an Oncurrent event to
insert default values if the current value is null.

If you can't get it to work then reply and I'll have another look at it.

http://office.microsoft.com/en-us/access/HA010550481033.aspx
 
sharontodd said:
I tried to post this earlier today, but it's not showing up when I do a
search so I'm trying again.

This has to be super easy but I can't find it in the forum or help. I am
trying to get certain fields to automatically fill in with the value from the
previous record. For instance, I have a form that inputs the details for
screen printing. There are fields for item and color, which typically are
the same for all or much of the record. After the user inputs values in the
first record, those values should automatically show up in the next field.
The user would be able to change them if they wanted.

Thanks for your help.

Sharontodd

You can use just a bit of VBA code on your form to do this. Open the form in
design view; select the textbox that you want to be "sticky" (txtColor let's
say); view its Properties. Click the ... icon by the AfterUpdate property and
choose Code Builder. Access will give you the Sub and End Sub lines; edit to

Private Sub txtColor_AfterUpdate()
Me!txtColor.DefaultValue = Chr(34) & Me!txtColor & Chr(34)
End Sub
 
Back
Top