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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem calling macro

Status
Not open for further replies.

ch4meleon

Technical User
Jan 13, 2003
60
GB
i have written a very basic macro and called it finduser i have attached it to a button but when i click the button i get an error message telling me it cant be found becasue it doesnt exist or is new and hasnt been saved yet. i have been in and out of the database & saved it but i still get the same error - ive not had this prob before and i dont think ive done anything differently to what i have done previously ??
any ideas please on what ive done wrong ?
thanks
 
It sounds like the button is expecting a VBA function and you are supplying a macro. You have two options in that case, ether convert the macro to vba or inform the button that it is a macro, not vba.

If you want to run the macro, your code in the On-click event of the button migh look something like this:

Code:
Private Sub Command422_Click()
On Error GoTo Err_Command422_Click

    Dim stDocName As String

    stDocName = "Macro1"
    DoCmd.RunMacro stDocName

Exit_Command422_Click:
    Exit Sub

Err_Command422_Click:
    MsgBox Err.Description
    Resume Exit_Command422_Click
    
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top