OnClick event does nothing

S

SM

Hi all,

I'm working in Access 2003 in a database created by several previous users.
I've added a command button to a form. Under the OnClick event I've added
VBA code to export data to an Excel spreadsheet. My problem is that when I
run the form and click the button nothing happens. When I click other
buttons on the form they function properly. I added a Stop comment to the
first line of the OnClick event in question, but the Visual Based editor
doesn't pop up when I run the form and click the button.

I'm at a loss as to why this is happening. Any ideas for troubleshooting or
solving this problem would be greatly appreciated!

Thanks,

Sean
 
B

box2003

Do you show an [Event Procedure] for On Click under the Event Tab? Could you
post your procedure syntax for review?
 
S

SM

On Click shows [Event Procedure] under the Event Tab.

The code under the event is:
_______________________________
Private Sub Command220_Click()
Stop
ExpMaintData
End Sub
_______________________________

ExpMaintData is a Private Sub located in the same form.

Could this have something to do with a security setting preventing the Sub
from running? That doesn't make sense to me since the other On Click events
on the forms work. Note that they only open reports, and the other On Click
events were generated by command button wizards, which might have something
to do with it (although I don't know how).

box2003 said:
Do you show an [Event Procedure] for On Click under the Event Tab? Could you
post your procedure syntax for review?

SM said:
Hi all,

I'm working in Access 2003 in a database created by several previous users.
I've added a command button to a form. Under the OnClick event I've added
VBA code to export data to an Excel spreadsheet. My problem is that when I
run the form and click the button nothing happens. When I click other
buttons on the form they function properly. I added a Stop comment to the
first line of the OnClick event in question, but the Visual Based editor
doesn't pop up when I run the form and click the button.

I'm at a loss as to why this is happening. Any ideas for troubleshooting or
solving this problem would be greatly appreciated!

Thanks,

Sean
 
B

box2003

Maybe reverse your code in the below manner
Private Sub Command220_Click()
ExpMaintData
Stop
End Sub

SM said:
On Click shows [Event Procedure] under the Event Tab.

The code under the event is:
_______________________________
Private Sub Command220_Click()
Stop
ExpMaintData
End Sub
_______________________________

ExpMaintData is a Private Sub located in the same form.

Could this have something to do with a security setting preventing the Sub
from running? That doesn't make sense to me since the other On Click events
on the forms work. Note that they only open reports, and the other On Click
events were generated by command button wizards, which might have something
to do with it (although I don't know how).

box2003 said:
Do you show an [Event Procedure] for On Click under the Event Tab? Could you
post your procedure syntax for review?

SM said:
Hi all,

I'm working in Access 2003 in a database created by several previous users.
I've added a command button to a form. Under the OnClick event I've added
VBA code to export data to an Excel spreadsheet. My problem is that when I
run the form and click the button nothing happens. When I click other
buttons on the form they function properly. I added a Stop comment to the
first line of the OnClick event in question, but the Visual Based editor
doesn't pop up when I run the form and click the button.

I'm at a loss as to why this is happening. Any ideas for troubleshooting or
solving this problem would be greatly appreciated!

Thanks,

Sean
 
B

Brotha Lee

May be you already tried this but can you try the following:
1) Copy you code of the Onclick event and paste it somewhere outside VBA
(e.g. Word)
2) Delete the entire onClick event by selecting all text in the VBA editor
3) Go back to your form and show the properties window
4) Go to tab event and on the click event add a new code
5) Access should jump to the VBA editor
6) Paste back the code.

HTH

box2003 said:
Maybe reverse your code in the below manner
Private Sub Command220_Click()
ExpMaintData
Stop
End Sub

SM said:
On Click shows [Event Procedure] under the Event Tab.

The code under the event is:
_______________________________
Private Sub Command220_Click()
Stop
ExpMaintData
End Sub
_______________________________

ExpMaintData is a Private Sub located in the same form.

Could this have something to do with a security setting preventing the Sub
from running? That doesn't make sense to me since the other On Click events
on the forms work. Note that they only open reports, and the other On Click
events were generated by command button wizards, which might have something
to do with it (although I don't know how).

box2003 said:
Do you show an [Event Procedure] for On Click under the Event Tab? Could you
post your procedure syntax for review?

:

Hi all,

I'm working in Access 2003 in a database created by several previous users.
I've added a command button to a form. Under the OnClick event I've added
VBA code to export data to an Excel spreadsheet. My problem is that when I
run the form and click the button nothing happens. When I click other
buttons on the form they function properly. I added a Stop comment to the
first line of the OnClick event in question, but the Visual Based editor
doesn't pop up when I run the form and click the button.

I'm at a loss as to why this is happening. Any ideas for troubleshooting or
solving this problem would be greatly appreciated!

Thanks,

Sean
 
S

SM

Thanks for the suggestions!

I tried them both but the code won't execute. When I placed the full code
in a Module I can't even Step In to the code (using F8) or Run to Cursor
(using Shift F8).

I suspect there are limitations on running VBA code in the database, though
I don't know how these limitations are set. When I check the security
settings in the database I have permission to run/edit/modify etc. all of the
tables/queries/forms/reports/macros.

I suspect I'll have to figure out another way to accomplist my goal without
using VBA!


Brotha Lee said:
May be you already tried this but can you try the following:
1) Copy you code of the Onclick event and paste it somewhere outside VBA
(e.g. Word)
2) Delete the entire onClick event by selecting all text in the VBA editor
3) Go back to your form and show the properties window
4) Go to tab event and on the click event add a new code
5) Access should jump to the VBA editor
6) Paste back the code.

HTH

box2003 said:
Maybe reverse your code in the below manner
Private Sub Command220_Click()
ExpMaintData
Stop
End Sub

SM said:
On Click shows [Event Procedure] under the Event Tab.

The code under the event is:
_______________________________
Private Sub Command220_Click()
Stop
ExpMaintData
End Sub
_______________________________

ExpMaintData is a Private Sub located in the same form.

Could this have something to do with a security setting preventing the Sub
from running? That doesn't make sense to me since the other On Click events
on the forms work. Note that they only open reports, and the other On Click
events were generated by command button wizards, which might have something
to do with it (although I don't know how).

:

Do you show an [Event Procedure] for On Click under the Event Tab? Could you
post your procedure syntax for review?

:

Hi all,

I'm working in Access 2003 in a database created by several previous users.
I've added a command button to a form. Under the OnClick event I've added
VBA code to export data to an Excel spreadsheet. My problem is that when I
run the form and click the button nothing happens. When I click other
buttons on the form they function properly. I added a Stop comment to the
first line of the OnClick event in question, but the Visual Based editor
doesn't pop up when I run the form and click the button.

I'm at a loss as to why this is happening. Any ideas for troubleshooting or
solving this problem would be greatly appreciated!

Thanks,

Sean
 
G

GH

On Click shows [Event Procedure] under the Event Tab.

The code under the event is:
_______________________________
Private Sub Command220_Click()
Stop
ExpMaintData
End Sub
_______________________________

ExpMaintData is a Private Sub located in the same form.

...
....

The first line of your subroutine looks like a "Stop" command, which
suspends execution. Have you tried commenting that line out?

HTH
- GH
 
G

GH

On Click shows [Event Procedure] under the Event Tab.
The code under the event is:
_______________________________
Private Sub Command220_Click()
Stop
ExpMaintData
End Sub
_______________________________
ExpMaintData is a Private Sub located in the same form.

...

The first line of your subroutine looks like a "Stop" command, which
suspends execution. Have you tried commenting that line out?

HTH
- GH- Hide quoted text -

- Show quoted text -

Okay, I should have finished my thoughts...

Once the stop breaks into your code execution, are you not able to
step into your called subroutine? Have you tried adding a new
subroutine to call that tests to see whether the call to
"ExpMaintData" is the problem as opposed to some other issue. You
could try creating and calling a completely different subroutine or
just add some sort of test message in the existing subroutine to see
if the click event is firing properly. If neither of these correct
the issue, try moving the called subroutine code into the click event
to see if it works there. You really need process of elimination to
determine if rights really are the issue.

- GH
 

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