Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Events not being triggered 1

Status
Not open for further replies.

billschu

Technical User
Apr 3, 2001
38
US
Hi,

I am using Access 2000 and have a number of events for various controls that are not being triggered when they should be. For example, I have a command button cmdPrint_Report. The event procedure looks like this:

Sub cmdPrint_Report_Click()

'print the report to the default printer
Call Module1.Print_Report

End Sub

Occasionally, it does not fire when the button is clicked. I have to close the form or Access itself re-open it for it to start working. Also, if I delete the sub, save, then add it back and save again, it will start working. This happens for several other controls and events as well (for example, lostfocus). Seems pretty random though and I can't figure out the rhyme or reason.

Is this a bug? Has anyone else experienced this problem?

Thanks,
Bill
 
Some of this sounds like what happens when you create an event procedure directly in the code window. Access sometimes fails to set the event property to [Event Procedure], especially if you paste in multiple procedures at once. It can happen when you change the name of a control, too.

I fight it by trying to always create event procedures by clicking the "..." button next to the event property.

The problem I'm talking about goes away if you save the form with all the event properties correct, and don't modify or add procedure headings after that. But it sounds like you may be seeing it work for a while and then fail, without intervening changes to the code.

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Yes, I was creating it directly from code, and when I go into the control properties I can see it is not tied to the event..

Your approach fixes the problem - thank you very much!

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top