Setting default value in form control from another control (1 Viewer)

PaulA

Registered User.
Local time
Today, 20:20
Joined
Jul 17, 2001
Messages
416
Greetings,

I want to set a default date value in a form control based on a date value in another control using the dateadd function. I want this default value to be able to be modified if needed.

Is this possible? The field remains blank even when there is a value in the source control. I used the function dateadd("d", 90, [SourceControlName]).

If this won't work, any suggestions?

Thanks!
 

Mark_

Longboard on the internet
Local time
Today, 12:20
Joined
Sep 12, 2017
Messages
2,111
Are both forms open when you do this?
Also, what event are you using to fill your field?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:20
Joined
Feb 19, 2002
Messages
43,774
Controls where the ControlSource starts with the equal sign or which are empty are NOT bound. Therefore, they would never be saved when the record is saved.

Storing a calculated value such as this violates second normal form. You can easily add the calculation to a query.

If you elect to violate rules of database normalization, put your calculation in the AfterUpate event of the first date field

Me.SecondDate = dateadd("d", 90, Me.[SourceControlName]).
 

PaulA

Registered User.
Local time
Today, 20:20
Joined
Jul 17, 2001
Messages
416
Thanks - the source field actually comes from another table and won't be updating it. I was hoping to use it for this form. I can do a dlookup and use that for the calculation.

thanks.
 

Mark_

Longboard on the internet
Local time
Today, 12:20
Joined
Sep 12, 2017
Messages
2,111
PaulA,

If you are saving it, you can also set a Default Value on the Data tab for the Text box in its properties. I am under the impression that your end users can change this in some cases?
 

Users who are viewing this thread

Top Bottom