Form control events get broken.

  • Thread starter DavidBoyle via AccessMonster.com
  • Start date
D

DavidBoyle via AccessMonster.com

My colleagues and I have a problem that occurs while designing access forms
and it isn't helped by the fact that our applications have a lot of buttons
on their forms.

The best way I can describe the problem is to explain how to repeat the
problematic behavior.

1) Create a blank form and stick a button on it and connect it to some code
say:

Private Sub Command6_Click()
MsgBox ("Hello World")
End Sub

2) Change the form to design view.

Right Click the button then do edit cut, edit paste from the main menu.

Right click the form title bar and choose form view.

Click the button in no longer works.

Go back to design view, right click the button and build event, you'll find
the cursor flashing away happily in the click event. Close the visual basic
editor put the form back in form view and the button works happily again.

Obviously I'd like to be able to cut and paste buttons without breaking their
events, but can anyone explain why the link to the code gets broken? It this
behaviour by design?
 
A

Allen Browne

The behavior is the way Access has always worked. If you cut/copy a button,
the code does not go with it. When you paste a control into a form that has
the right code for an event procedure, the relevant property does not get
set to [Event Procedure].

It does work the other way round, though. After pasting controls in, you can
go to the code window, select all the code (Ctrl+A), cut (Ctrl+X), and paste
(Ctrl+V.) You will find that Access does set the relevent properties to
[Event Procedure] for the controls on the form.

If you have not yet discovered MZ Tools (mztools.com), it does provide a way
to cut/paste controls and their code.
 
D

DavidBoyle via AccessMonster.com

Thanks so much - David

Allen said:
The behavior is the way Access has always worked. If you cut/copy a button,
the code does not go with it. When you paste a control into a form that has
the right code for an event procedure, the relevant property does not get
set to [Event Procedure].

It does work the other way round, though. After pasting controls in, you can
go to the code window, select all the code (Ctrl+A), cut (Ctrl+X), and paste
(Ctrl+V.) You will find that Access does set the relevent properties to
[Event Procedure] for the controls on the form.

If you have not yet discovered MZ Tools (mztools.com), it does provide a way
to cut/paste controls and their code.
My colleagues and I have a problem that occurs while designing access
forms
[quoted text clipped - 32 lines]
this
behaviour by design?
 

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