Controling default value.

E

Eugene

Can a default value be controled by an if statement?

Example:

if time_assigned >= 0800 and <= 1100 then........

Thanks,

Eugene
 
K

ken

Eugene:

Only if time_assigned is an unbound control, whose value has been
already set. The DefaultValue property of a control places a value in
a control when a form moves to a new record, so at this stage there
will be no value for time_assigned if this is a bound control, so the
property can't be set conditionally. What can be done, however, is
assign a value to the relevant control in the AfterUpdate event
procedure of the time_assigned control:

If Me.time_assigned >= 800 And Me.time_assigned <= 1100 Then
Me.SomeOtherControl = "Foo"
Else
Me.SomeOtherControl = NULL
End If

This will assign the value 'Foo' to the other bound control, which is
assumed to be a text data type, if a value between 800 and 1100 is
entered in time_assigned, which is assumed to be a number data type.
If the value entered in time_assigned is outside the range then the
other control will be set to Null, but can then have a value entered
manually of course.

If time_assigned is a text data type its values should be wrapped in
quotes in the code, "0800" and "1100". Conversely, if
SomeOtherControl holds a value of number data type the value assigned
to it should not be wrapped in quotes, e.g. 123. If by any chance a
date value is to be entered then it should, if a date literal is used,
be in an internationally unambiguous format and wrapped in the # date
delimiter characters, e.g. #2009-02-20#, using the ISO date format
standard of YYYY-MM-DD in this case.

Ken Sheridan
Stafford, England
 
Top