Change Control Source

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.
 
M

Marshall Barton

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"
 
G

gllincoln

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
 
N

NNlogistics

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

Thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top