Dynamic default of text field possible? (1 Viewer)

Kingz

Member
Local time
Today, 15:45
Joined
Mar 19, 2024
Messages
39
A user of my form would like a default date appearing in a text field of the form. This default is to be the last date used on that field.. Is it possible to store this date in the default property. I realise the user would need to save the application at that point, in order for it to remain..I just can't find the default property in VBA
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:45
Joined
May 21, 2018
Messages
8,593
You do not save this value you assign it dynamically. Most likely it is on the forms current event. Probably something like

me.Somecontrol.defaultvalue = nz(dmax("dateField","someTable"),date())
 

topdesk123

Registered User.
Local time
Today, 06:45
Joined
Mar 28, 2013
Messages
53
you can set the default value in the table like this:
1714400762277.png
 

Kingz

Member
Local time
Today, 15:45
Joined
Mar 19, 2024
Messages
39
You do not save this value you assign it dynamically. Most likely it is on the forms current event. Probably something like

me.Somecontrol.defaultvalue = nz(dmax("dateField","someTable"),date())
I tried it on form_current() but it didn't work.. Actually instead of looking in the table I wanted it to just take what was in the text.value as default for next time

Form_current()
If not isnull(me.txtdate.value) then
Me.txtdate.defaultvalue = me.txtdate.value
End if
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:45
Joined
May 21, 2018
Messages
8,593
If you wanted to do it that way, then you cannot do it on the current event. Because that would pull the value from the current record.
You could try in the after update of the record, so that the next record gets the last records date. This will not work the next time you open the form.
If you want to persist the value so you are always pulling the last date whenever you add or update then you really need to go to the table level.
 

Users who are viewing this thread

Top Bottom