As June7 said, you can use the AfterUpdate event of the Control holding your data to set the DefaultValue for the Field. From that time forward, until you either manually change the data or close your form, the data will be entered automatically in each New Record.
The syntax for each Datatype is slightly different, or you can use this syntax
Code:
Private Sub YourControlName_AfterUpdate()
Me.YourControlName.DefaultValue = """" & Me.YourControlName.Value & """"
End Sub
which is valid for Text, Number and Date Datatypes. Never tried it on a Yes/No Field!
You’ll need to do this for each Control that you want to ‘carry forward.’
If you have a slew of Fields, you can use the Tag Property to mark the ones to be defaulted and then loop through them, setting the DefaultValue.
- In Form Design View
- Select all Controls you want to 'carry forward,' by pressing and holding down the <Shift> Key and clicking on each one.
- Go to Properties - Other
- In the Tag Property enter CarryForward (without quotes)
Now use this code:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "CarryForward" Then
ctl.DefaultValue = """" & ctl.Value & """"
End If
Next ctl
End Sub
Each of the "tagged" Controls' values will be carried forward into a New Record until you either Edit the data in a given Control or Close the Form or Access itself.
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007