Using VBA to define the ControlSource property of an unbound field

  • Thread starter Thread starter Melissa
  • Start date Start date
M

Melissa

I have a text field in a subform which should display a result based
on the user's selection in a combo box (cboEndDate) in the main form.
I've gotten the code written in a sub named daycalc(), but can't
figure out how to get the subform to recognize this code as its
controlsource. It's just simply blank. How do you get the field in
the subform to recognize the VBA as its controlsource? If you need
more details, I'm glad to provide them. I'm hoping that this is a
simple thing that I'm just overlooking.
 
dayCalc() is a Function not a Sub right?

Where is this Function?

If daycalc() is in the subform's module, you should set the controlsource of
your textbox to '=daycalc()' then all you need to do is Requery the textbox
in the AfterUpdate event of the combo on the main form, assuming daycalc()
gets the value of the combo?

Steve
 
Thanks, Steve. daycalc() is a sub. I do, however, have a function
named function_daycalc() that calls the sub. So I assume that I'd use
the controlsource of the textbox as =function_daycalc().

Yes, daycalc() does get its value from the combo.

I'll give this a try. Thanks!
 
Back
Top