Use Last Record Value as Default

matt beamish

Registered User.
Local time
Today, 08:37
Joined
Sep 21, 2000
Messages
215
On a Form is there a simple way to use the value entered in the last record as a default value in the next record. I have done this using Combo boxes, but not on a Text Box.

Help appreciated

Matt
 
Use an append query activated by a command button to add your new record.

Use [forms]![frmName]![ItemID] in the criteria of your query (under the ItemID or what ever you choose as the unique recordID) and choose the data you wish to copy into the new record.
 
Thanks, Ill give it a go

Matt
 
You don't need to use a query for this simple task, simply assign the value last entered into the DefaultValue for the textbox in the AfterUpdate event.

For a text value
Code:
Private Sub YourTextControlName_AfterUpdate()
If Not IsNull(Me.YourTextControlName.Value) Then
  YourTextControlName.DefaultValue = """" & Me.YourTextControlName.Value & """"End If
End Sub

For a numeric value
Code:
Private Sub YourNumericControlName_AfterUpdate()
If Not IsNull(Me.YourNumericControlName.Value) Then
  YourNumericControlName.DefaultValue = Me.YourNumericControlName.Value
End If
End Sub
Good Luck!

Linq
 
Default is changing all records

Good morning,

I am looking to change the default value for new records based on the last value entered.
I used your code from this post but it changes all values in all records. I would like it to apply to new records only.

Any ideas.

Thanks

Jerry
 

Users who are viewing this thread

Back
Top Bottom