gbnorton
asked on
Access 2007 function call from Macro
How do I call a function created in Access 2007 Visual Basic with a Macro?
In a test database I created a simple Global function to display a message box. Now I want to display it by calling it with a macro assigned to a command button.
Thanks,
Brooks
In a test database I created a simple Global function to display a message box. Now I want to display it by calling it with a macro assigned to a command button.
Thanks,
Brooks
Or get rid of the macro and call it in VBA
Private Sub cmd_YourButton_Click
Call NameOfFunction
End Sub
Or if it returns a value, as all functions should, otherwise they should be subroutines
Private Sub cmd_YourButton_Click
'assumes the function returns an integer
Dim intRetValue as integer
intRetValue = NameOfFunction()
End sub
Private Sub cmd_YourButton_Click
Call NameOfFunction
End Sub
Or if it returns a value, as all functions should, otherwise they should be subroutines
Private Sub cmd_YourButton_Click
'assumes the function returns an integer
Dim intRetValue as integer
intRetValue = NameOfFunction()
End sub
ASKER
I get the error: The expression you entered has a function name Microsoft Office Access cannot find.
In Visual Basic I have this code in Module1:
Public Sub Test()
MsgBox "Test"
End Sub
In the Macro editor I have:
Action Arguments
RunCode Test()
Thanks for your help.
In Visual Basic I have this code in Module1:
Public Sub Test()
MsgBox "Test"
End Sub
In the Macro editor I have:
Action Arguments
RunCode Test()
Thanks for your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the quick help.
Action
Runcode
Function Name NameOfFunction()