In a Form I have a Date field which is repeated many times from the previous Record. Is there any type of format or rule I can create whereby when I enter into a new Record the date from the preceding Record will automatically be entered?
In a Form I have a Date field which is repeated many times from the previous Record. Is there any type of format or rule I can create whereby when I enter into a new Record the date from the preceding Record will automatically be entered?
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.
Note that this code/syntax can be used for any Datatype, including Dates.Code:Private Sub YourControlName_AfterUpdate() Me.YourControlName.DefaultValue = """" & Me.YourControlName.Value & """" End Sub
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007
I was unsuccessful at conquering my quest. Following the link that you provide assumingly I copied & pasted the code in VBA which didn’t work
Private Sub YourControlName_AfterUpdate()
Me.YourControlName.DefaultValue = """" & Me.YourControlName.Value & """"
End Sub
I also tried to copied/pasted the code below in VBA which didn’t work either.
End SubM
- Private Sub YourControlName_AfterUpdate()
- Me.YourControlName.DefaultValue = """" & Me.YourControlName.Value & """"
Maybe I’m not understanding these codes & what to do with them. Might you offer some further instructions or have other suggestions?
You would need to replace YourControlName with the actual name of yours, and enter the code via this path:
http://www.baldyweb.com/FirstVBA.htm