Temporary default value (1 Viewer)

jwf

Registered User.
Local time
Today, 03:49
Joined
Dec 5, 2012
Messages
18
How do you assign a default value from the last record or use a temporary default value in a form
 

bob fitz

AWF VIP
Local time
Today, 11:49
Joined
May 23, 2011
Messages
4,729
You could use some code in the forms After UpDate event to set the Default Value property of a control to the value of that record.
Something like:
Code:
Private Sub Form_AfterUpdate()
 Me.ControlName.DefaultValue = """" & Me.ControlName& """"
End Sub
Replace ControlName with the name of your control.
 

MarvinM

Registered User.
Local time
Today, 03:49
Joined
Nov 26, 2013
Messages
64
jwf,

I saw an idea like this in another forum. The idea was to set the default values with a button. Say you have several/many records to input and in this batch, all the City, State, and Zips are "San Francisco", "CA", and "94132". His idea was to enter the first record and then click on a "Set Defaults" button (pick a name that makes it easy for your users), and that would temporarily store the values as defaults, so that the user doesn't have to re-enter the same thing again, and again, and agian, avoiding typos! Here's the code:
Code:
Private Sub btnStore_Click()
 
   Me.txtCity.DefaultValue = """" & Me.txtCity & """"
   Me.txtState.DefaultValue = """" & Me.txtState & """"
   Me.txtZip.DefaultValue = """" & Me.txtZip & """"
 
End Sub
HTH
_________________
Regards,
Marvin M :cool:
Windows 7 Professional, MS Access 2007/2010
Windows 8 Professional, MS Access 2013
---------------------------------------------------------------------------------------------
If my post has helped you, please click the scales or click the 'Thumbs up'. Thanks!
---------------------------------------------------------------------------------------------
 

Mihail

Registered User.
Local time
Today, 13:49
Joined
Jan 22, 2011
Messages
2,373
How do you assign a default value from the last record or use a temporary default value in a form
"The last record" is very relative. This notion imply a sort order. (this is only regarding to the terminology).
Regarding to your question, my practice is to use the DoubleClick event in order to set the default value.
So, for each control where I like to set the default value I have this code:
(From the top of my head)
Private Sub MyControl_DoubleClick()
MyControl.DefaultValue = MyControl
End Sub

I think that this link can be also a help for you:
http://www.access-programmers.co.uk/forums/showthread.php?t=257875
 

Users who are viewing this thread

Top Bottom