Last record default

AndyMcC

New Member
Joined
Nov 27, 2003
Messages
10
How can I display "last record" information on a form in add mode.

I have a set of 50 variables to input to an Excel calculation via an Access form, the variables then being stored in an Access database. Although all these variables have the potential to change, in reality only a handful of them actually change from calculation to calculation.

What I need to be able to do is display the last record values as a default setting on the form, whilst the act of opening the form will create a new record.

Any ideas? :rolleyes:
 

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

bat17

Well-known Member
Joined
Aug 15, 2003
Messages
1,470
Here is some code, it is old and not well formed but it works :)

Code:
Sub Up_Date()
Dim This_Form_Name As String
Static pc As String
Static bat As String
Static pn As String
Static v As String

On Error GoTo update_error_trap
This_Form_Name = Screen.ActiveForm.Name
DoCmd.GoToRecord acForm, This_Form_Name, acLast
 pc = Screen.ActiveForm![Product Code]
 pn = Screen.ActiveForm![Product Number]
 bat = Screen.ActiveForm![Batch Number]
 DoCmd.GoToRecord acForm, This_Form_Name, acNewRec
 Screen.ActiveForm![Product Code] = pc
 Screen.ActiveForm![Product Number] = pn
 Screen.ActiveForm![Batch Number] = bat
 Screen.ActiveForm![Product Code].SetFocus
 Screen.ActiveForm![Product Number].SetFocus
 Screen.ActiveForm![Roll Number].SetFocus
update_error_trap:
End Sub

this code works from a hotkey but it should give you some ideas.

HTh

Peter
 

Watch MrExcel Video

Forum statistics

Threads
1,122,370
Messages
5,595,768
Members
414,017
Latest member
surajks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top