G
Guest
I am attempting to set the default value of a combo box dynamically in VBA. I
do this often, but in one particular case, it is not working.
- I have verified that the default value property is being set correctly;
however, the control does not pick up the default value on new records, but
remains empty (not null, however)
- The control picks up the default value correctly if I instead set it in
the control's property sheet.
- The entire process works fine for another control on the same form.
- I have delete & recreated the faulty control, to no avail.
- The value is not being left null; I inserted the following code in
Form_Current:
If IsNull(ControlName) Then
MsgBox "Null"
Else
MsgBox ControlName.Value
End If
This does not generate "Null", but rather a runtime error 2447: "There is an
invalid use of the .(dot) or ! operator or invalid parentheses"
I can successfully set the value manually in Form_Current thus:
ControlName = ControlName.DefaultValue
Why would a particular control not be picking up its default value
automatically?
do this often, but in one particular case, it is not working.
- I have verified that the default value property is being set correctly;
however, the control does not pick up the default value on new records, but
remains empty (not null, however)
- The control picks up the default value correctly if I instead set it in
the control's property sheet.
- The entire process works fine for another control on the same form.
- I have delete & recreated the faulty control, to no avail.
- The value is not being left null; I inserted the following code in
Form_Current:
If IsNull(ControlName) Then
MsgBox "Null"
Else
MsgBox ControlName.Value
End If
This does not generate "Null", but rather a runtime error 2447: "There is an
invalid use of the .(dot) or ! operator or invalid parentheses"
I can successfully set the value manually in Form_Current thus:
ControlName = ControlName.DefaultValue
Why would a particular control not be picking up its default value
automatically?