I cannot running a function with macro

masoud_sedighy

Registered User.
Local time
, 17:20
Joined
Dec 10, 2011
Messages
132
When I click the buttonA in my form, it runs a macro that there are some update query and a RunCode Action inside that.
update queries will be run buy RunCode does not execute function

Function Name of that is Update_Trend_Line_by_Month ()
I have made a module and put this function inside that:

Public Function Update_Trend_Line_by_Month()

Dim qdef As DAO.QueryDef
Set qdef = CurrentDb.CreateQueryDef("")
qdef.Connect = CurrentDb.TableDefs("[ASBUILT_LIST]").Connect
qdef.SQL = "EXEC Update_Asbuilt2"
qdef.ReturnsRecords = False ''avoid 3065 error
qdef.Execute

MsgBox "As Built list updated"

End Sub

when I click ButtonA Update queries will be execute but function Update_Trend_Line_by_Month () does not execute.

But when I put the code of this single function (VBA) to the button click event of another form it runs without problem.
But when it is inside macros with some other actions like update queries,
will be run but function does not execute.

Please help how I can solve my problem.
 
The module doesn't have the same name as the function, does it?
 
Name of module is ( module1)
 
Is the function argument of RunCode

Update_Trend_Line_by_Month()

If so, that should work. What does the whole macro look like? I don't use them, but it might help to see it all.
 
Hi. Is your file stored in a Trusted Location or did you click the Enable Content button?
 
I don't think the other things would be running if not.
 

Users who are viewing this thread

Back
Top Bottom