Error solved but it doesn't work - Sorry!!! I missed out 'Case'. How? don't ask me!
My brain is following the wrong path. Please advise the right path.
I have two controls and a 'doit' button. I click either control and wish to know which before sending text from another control to it, so that the correct format goes to the correct control. Having clicked (selected the destination control) I click the 'doit' button. I cannot simply use sender because the last sender is 'doit'.
I chose to store the original sender then when pressing 'doit' use 'select' to differentiate. An error in the doit sub says that the variable (the stored sender) is not used in sub.
[Edit] I have tried quotes around the 'Select' items but it is not accepted.
The code principle (to shorten) follows
sub controlA_click
gWhereTo=sender.name
do some things and formats
end sub
sub controlB_click
gWhereTo=sender.name
do different things and different formats
end sub
sub doit_click
Select gWhereTo
controlA
Control(gWhereTo).text=text from another control but formatted by controlA
controlB
Control(gWhereTo).text=text from another control but formatted by controlB
end select
I apologise. After a lot of hair pulling I suddenly realised I had missed the keyword Case.
I cannot imagine how such stupidities occur.
The error is solved but it doesn't actually work now I have Case "controlA" etc. so advice still needed please.
[edit] NOW I HAVE SOLVED IT. I have used the control name as it appears (and was set) in the form designer. i.e. IntCount.
When using the control name from Sender it returns it as lowercase, intcount and so did not match the Case Statement.
I apologise for this 'red herring' and still cannot find the reference that says that the name is returned as lower case.
Can somebody please refer me.
Thank you Zenerdiode, I am sure that he will get to it in due course.
Unfortunately with me, just because I know it now, doesn't mean I'll remember next week.