Link to home
Start Free TrialLog in
Avatar of gksewell
gksewell

asked on

MS Access event assignmts

Have 4 buttons same code for retieving word doc and retrival works fine
However, event procedure doesn't save when assigning to different buttons
Is this an incorrect prcedure? Saving ode to a command button seems intuitive but when moving to recording to the following buttons seems to erase the event procedure on the previous button.
any suggstions helpful
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

have you done a compact and repair?

why 4 buttons doing the same thing?
Avatar of gksewell
gksewell

ASKER

each button pulls up a differnet word template for data merge
just redid event assignments to each button but only the last button retains the event procedure.
yes did compact & repair
how did you do "event assignments" ?

is your form in design view when you were doing the event assignments?
yes always in design view when configuring
can you upload a copy of your db.
these are the 4 events for the 4 cmd buttons

Private Sub Command106_Click()

Dim mydoc As String
mydoc = "C:\Users\sewellg\Desktop\New Router Config Tool 2\DC2 VPN Router.docx"
Application.FollowHyperlink mydoc

End Sub

Private Sub Command107_Click()

Dim mydoc As String
mydoc = "C:\Users\sewellg\Desktop\New Router Config Tool 2\DC2 VPN Tunnel.docx"
Application.FollowHyperlink mydoc

End Sub

Private Sub Command108_Click()

Dim mydoc As String
mydoc = "C:\Users\sewellg\Desktop\New Router Config Tool 2\DC1 VPN Router.docx"
Application.FollowHyperlink mydoc

End Sub

Private Sub Command109_Click()

Dim mydoc As String
mydoc = "C:\Users\sewellg\Desktop\New Router Config Tool 2\DC1 VPN Tunnel.docx"
Application.FollowHyperlink mydoc

End Sub
Router-Builds1.accdb
ASKER CERTIFIED SOLUTION
Avatar of Nick67
Nick67
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
first open the form that have your 4 command buttons

select one command button, then hit F4
select the Event Tab and look for the On Click event
click the drop down arrow and select [Event Procedure]
then click the (...) this will take you to the VBA window..
Only the 1st button worked that is what I had to start with
I was following your procedure since yesterday a few dozen times and when one proceeds to the next button it erases previous procedure for previous button even saving and geting out and back into DB
Your db did show the Event click process in each property box but if I use the .... then it starts a new instance.
Appreciate your patience.
< if I use the .... then it starts a new instance.>
this instance is the one that you must use..

also, it will be a lot easier for you to read your codes if you will give your controls, command buttons in this case, a meaningful name not command1, command 2 etc...
Ok here is your sample again.
Each button is wired up
Each button has identical code in it
The code survived a compact & repair.
You will need to alter the code to match the filenames you actually want to open.

Unlike VB6 and VB.NET, each control MUST have it's own event handler.
Stuff like

Private Sub OpenFile() Handles command106_click(),command107_click() ...

is not valid.

You have 4 controls
Each is wired up with a click [Event Procedure]
Each event exists in the code module.
Check the sample.

With accdb files EE is broken at the moment.
You must right-click the file and Choose Save As.
Then Choose All Files
And then give it an .accdb ending
Router-Builds1.accdb
thanks for all the professional help and your Patience.