f



copying controls from a form to a tab control

I have copied approx 20 controls from a form to a tab control for
reasons of space.

i now cannot run code triggered by the events of these controls.

for example, the following will not trigger the message box when
changed:

Private Sub cboA_Change()
  MsgBox "combo A changed"
End Sub

the controls are all disabled and are only enabled when the previous
control has a value set.

any ideas?

thanks

Winshent
0
6/11/2004 4:17:40 PM
comp.databases.ms-access 42670 articles. 0 followers. Post Follow

3 Replies
536 Views

Similar Articles

[PageSpeed] 5

Winshent,

Instead of copying and pasting, try cutting and pasting.  If you copy and
then paste, the original controls stay on the form so when you paste the new
controls get new names and not the names you chose which means that even if
you then delete the original controls, the new controls will still have new
names and therefore no events associated with them.

Situation:
cboA gets copies and pasted.
Access changes the name to something like Combo294
You then delete cboA.
Your Module now has cboA_Change() but there is no control named cboA
Combo294 now exists, and looks the same, but has no events associated with.

Make sense?

-- 
Jeremy Shapiro
Asandia, Corp.
www.asandia.com
1.866.ASANDIA (272.6342)


"winshent" <vincent.pirolli@btinternet.com> wrote in message
news:c86c3b5e.0406110817.64d9c0f3@posting.google.com...
> I have copied approx 20 controls from a form to a tab control for
> reasons of space.
>
> i now cannot run code triggered by the events of these controls.
>
> for example, the following will not trigger the message box when
> changed:
>
> Private Sub cboA_Change()
>   MsgBox "combo A changed"
> End Sub
>
> the controls are all disabled and are only enabled when the previous
> control has a value set.
>
> any ideas?
>
> thanks
>
> Winshent


0
6/11/2004 7:20:28 PM
On Fri, 11 Jun 2004 15:20:28 -0400, "Jeremy B. Shapiro"
<jeremy-newsgroups@asandia.com> wrote:

>Winshent,
>
>Instead of copying and pasting, try cutting and pasting.  If you copy and
>then paste, the original controls stay on the form so when you paste the new
>controls get new names and not the names you chose which means that even if
>you then delete the original controls, the new controls will still have new
>names and therefore no events associated with them.
>
>Situation:
>cboA gets copies and pasted.
>Access changes the name to something like Combo294
>You then delete cboA.
>Your Module now has cboA_Change() but there is no control named cboA
>Combo294 now exists, and looks the same, but has no events associated with.
>
>Make sense?

Also, if you have cut and paste the controls, there's a good chance
that those controls' events will no longer associated with the
controls, even if they are in the form's module. One quick I have
found to deal with this is within the module: ctrl-A (to highlight
everything), ctrl-X to cut, ctrl-V to paste. The cutting and pasting
of all the code will cause all the events to become re-associated with
their controls.

Chuck
0
6/12/2004 2:55:54 AM
Chuck Van Den Corput <NOSPAMcvandencorput@sympatico.ca> wrote in message news:<g0skc0pds3pbcqpg4nf7gvao6i2aco5qjs@4ax.com>...
> On Fri, 11 Jun 2004 15:20:28 -0400, "Jeremy B. Shapiro"
> <jeremy-newsgroups@asandia.com> wrote:
> 
> >Winshent,
> >
> >Instead of copying and pasting, try cutting and pasting.  If you copy and
> >then paste, the original controls stay on the form so when you paste the new
> >controls get new names and not the names you chose which means that even if
> >you then delete the original controls, the new controls will still have new
> >names and therefore no events associated with them.
> >
> >Situation:
> >cboA gets copies and pasted.
> >Access changes the name to something like Combo294
> >You then delete cboA.
> >Your Module now has cboA_Change() but there is no control named cboA
> >Combo294 now exists, and looks the same, but has no events associated with.
> >
> >Make sense?
> 
> Also, if you have cut and paste the controls, there's a good chance
> that those controls' events will no longer associated with the
> controls, even if they are in the form's module. One quick I have
> found to deal with this is within the module: ctrl-A (to highlight
> everything), ctrl-X to cut, ctrl-V to paste. The cutting and pasting
> of all the code will cause all the events to become re-associated with
> their controls.
> 
> Chuck

thanks.. 

I did actually cut and paste (not copy and paste as described
above-incorrect statement). So i couldn't understand why all the code
was no longer working... even though the control names hadn't changed.

chuck... with regards to selecting all>cutting>pasting all code in the
module.. I will save the module with empty code and then repaste it..
but if this doesnt work then what should i try? wont be able to work
on this til monday now.

thanks again
0
6/12/2004 2:15:09 PM
Reply: