Problems with command buttons...get error message

pablotx

Registered User.
Local time
Today, 22:59
Joined
Feb 20, 2003
Messages
79
I am trying to place a find button and a print record button on my form. After I do it, I get this error message when I click either of the buttons. I am able to place buttons on some of my other forms in this database, but this form is different in that it is derived from a many to many relationship. I am thinking that has something to do with my problem. I have looked into the Event Procedure property of the on Click and from my limited knowledge, it looks fine. Do you have any ideas?

Private Sub Command148_Click()
On Error GoTo Err_Command148_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

Exit_Command148_Click:
Exit Sub

Err_Command148_Click:
MsgBox Err.Description
Resume Exit_Command148_Click

End Sub


The expression On Click you entered as the event property setting produced the following error.

*The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event or macro.

I am presuming that the error is the latter of the two.

I can post the form or entire database later if you think it will help.
 
It never hurts to be thorough. Just for giggles, in design mode you should open the properties for Command148 to verify that its OnClick event correctly points to the event code. If it says [Event Procedure] in the Click event slot then your surmise that it is the second error option is probably a good one.

Once that is eliminated, the issue is to somehow decide what, if anything, has been selected for the DoCmd.PrintOut acSelection command. The only thing that comes to mind is to debug it and open the debug window to look at the local objects. One of the object properties that you might be able to find is the Selection. If that property suggests that a selection exists, then you have found a real problem.

I'm not sure but I think the Selection is a part of the form object because that is what has to be open at the time. Since object properties are alphabetically presented, it should not be too hard to open every local object one at a time and scroll quickly to the beginning of the "S" properties to see if the object bears a Selection property and if so, what is its value.
 
This error can occur when there is a misspelled name of a function or macro in your OnClick property (not OnClick event procedure - there's a difference).

Check the OnClick PROPERTY to see if something invalid is there.

Hope this helps,
 

Users who are viewing this thread

Back
Top Bottom