Change Control Source

  • Thread starter Thread starter NNlogistics
  • Start date Start date
N

NNlogistics

I am using one form for two slightly different purposes. I want to be able
to have one txt box have 2 different Data control source's.

1 = existing customer 2 =new customer


So something like "on open event"
if "txtboxusedTodiffertiatebetweenforms =1 then
me.txtboxXXXXX.property.ControlSource = tblx.fld1
else
me.txtboxXXXXX.property.ControlSource = tbly.fld2
end if

In short can I change the control source on the fly.

I hope this is fairly clear.
 
NNlogistics said:
I am using one form for two slightly different purposes. I want to be able
to have one txt box have 2 different Data control source's.

1 = existing customer 2 =new customer


So something like "on open event"
if "txtboxusedTodiffertiatebetweenforms =1 then
me.txtboxXXXXX.property.ControlSource = tblx.fld1
else
me.txtboxXXXXX.property.ControlSource = tbly.fld2
end if

In short can I change the control source on the fly.


You can do that, but you can not reliably check the value of
a field or control in the form'sOpen event. If the form's
record source only returns one record, you could do it in
the Load event, however, I think the form's Current event is
more general an will work with multiple records in single
form view.

Your syntax is not quite right either. it should be more
like:

Me.textboxXX.ControlSource = "fld1"
or
Me.textboxXX.Properties!ControlSource = "fld1"
 
Hi,

When I do this - I tend to use two textboxes, toggling the visible property
for the textbox and label as I need to switch them - placing them exactly on
top of each other. To insure they are always one or other but not both, I
call the same sub, passing a value to select which one should be on and turn
the other one off, for every transitioning event that takes place.

Just an alternative to consider... makes keeping track of what bound
control/values you are referencing elsewhere, a little bit easier.

YMMV,
Gordon
 
Thans to both of you. I usually take the visible, invisible approach. I
just wanted to try something different.

Thanks again
 
Back
Top