change control property

  • Thread starter Thread starter smk23
  • Start date Start date
How can I programmatically change the value of a control default?

Thanks!

Sam

Change it when? To what?

I'll guess that this is what you mean.

For each control on your form that you wish to carry over to the next
new record .....
If the field is NOT a Date datatype, code that control's AfterUpdate
event:

Me![ControlName].DefaultValue = """" & Me![ControlName] & """"

If the field is a Date datatype, then code that control's AfterUpdate
event:

Me![DateField].DefaultValue = "#" & Me![DateField] & "#"

You'll have to enter the value just once per session.
It will remain the same for each new record until changed.
 
Thanks for looking at this, Fred.
I pass a control and value into a sub routine:

Private Sub sReportDefault( _
ByRef ctReport As Control, _
lngReportTemplateID As Long)
On Error GoTo Error_Handler

ctReport.DefaultValue = lngReportTemplateID
....

With this code, the default value of ctReport is not changing. When I debug,
ctReport shows the value of the control, not the control itself.

fredg said:
How can I programmatically change the value of a control default?

Thanks!

Sam

Change it when? To what?

I'll guess that this is what you mean.

For each control on your form that you wish to carry over to the next
new record .....
If the field is NOT a Date datatype, code that control's AfterUpdate
event:

Me![ControlName].DefaultValue = """" & Me![ControlName] & """"

If the field is a Date datatype, then code that control's AfterUpdate
event:

Me![DateField].DefaultValue = "#" & Me![DateField] & "#"

You'll have to enter the value just once per session.
It will remain the same for each new record until changed.
 
Back
Top