Dynamic default of text field possible?

Kingz

Member
Local time
Today, 07:39
Joined
Mar 19, 2024
Messages
63
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
 
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())
 
you can set the default value in the table like this:
1714400762277.png
 
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
 
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

Back
Top Bottom