Link to home
Start Free TrialLog in
Avatar of gupshup
gupshup

asked on

Error when running a macro to run a module

I am trying to test out my module so I have created a macro to run the module.  The macro calls the function partb_gg however when i run the macro i get an error msg: microsoft access cannot find the name partb_gg you entered into the expression.  I have doubled checked the name of the function on the module and it matches with the name that the macro is calling.
Avatar of jerryb30
jerryb30
Flag of United States of America image

Can you post the module code?
Or do the function and module have the same name?
Avatar of gupshup
gupshup

ASKER

Below is the module.

Option Compare Database

Function partb_gg()
On Error GoTo Test_Delete_Err_partb

DoCmd.RunSQL "DELETE *  FROM B_Reject_Fact_Monthly where month = [Enter B_Reject Month to Delete:] and year = [Enter B_Reject Year to Delete:]", -1



DoCmd.RunSQL "INSERT INTO B_Reject_Fact_Monthly" & _
" ( prv_id, wk_ending_dt, wk, [month], [year],rej_cd, rej_cd_cnt, reject_total )" & _
" SELECT a.prov_numb, GetWeekEndDate([deny_code]) as WeekEndDate, DatePart('ww',denial_date]) AS wk," & _
" Month([denial_date]) AS [month], Year([denial_date]) AS [year], 'testing' as rej_cd_cnt,'testing' as reject_total" & _
" FROM part_b_rejs AS a WHERE (((Month([WeekEndDate])) = [Enter B_Reject Month to Insert:])" & _
" And ((Year([WeekEndDate])) = [Enter B_Reject Year to Insert:])) Group BY a.prv_id, DatePart('ww',[denial_date])," & _
" Month([denial_date]), Year([denial_date]), GetWeekEndDate([deny_code]), a.rej_cd;"

Test_Delete_partb_Exit:
    Exit Function

Test_Delete_Err_partb:
    MsgBox Error$
    Resume Test_Delete_partb_Exit

End Function
ASKER CERTIFIED SOLUTION
Avatar of jerryb30
jerryb30
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gupshup

ASKER

It asks for a month then a year. when i put in january and 2007 it then says 'datatype mismatch'
Avatar of gupshup

ASKER

I figured it out.  The macro needs () after the function name.
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Yep ....