No, that would require opening the form in design view.
You could do the following:
- Create a new table in design view.
- Add a single field of type Date/Time and name it DefaultDate.
- Save the table as tblSettings.
- Open the table in datasheet view.
- Enter a date, for example today's date, or whatever you prefer.
- Add the following code to the On Load event of the form:
Code: Select all
Me.txtDate.DefaultValue = Chr(34) & DLookup("DefaultDate", "tblSettings") & Chr(34)
Edit the code for the button as follows:
Code: Select all
Private Sub btnSetDate_Click()
' Set the new default value
Me.txtDate.DefaultValue = Chr(34) & Me.txtDate & Chr(34)
' Store the default value in tblSettings
CurrentDb.Execute "UPDATE tblSettings SET DefaultDate=# & Format(Me.txtDate, "yyyy-mm-dd") & "#", dbFailOnError
End Sub