VBA Help - to run one function based on another

Ste4en

Registered User.
Local time
Today, 20:13
Joined
Sep 19, 2001
Messages
142
I want to combine the two functions below into one. I want to press one button on the switchboard and If macMissing returns more than zero rows, I want to run macMissing and show the query result. If it has zero rows I want it to run macCombine.

How do I modify these converted macros to do that.

thanks



Code:
Function macCombine()
On Error GoTo macCombine_Err

    DoCmd.SetWarnings False
    DoCmd.OpenQuery "ZqryCombinedToOverwriteWeeklyActuals", acViewNormal, acReadOnly
    DoCmd.OpenQuery "qryDeleteWeeklyActuals", acViewNormal, acEdit
    DoCmd.OpenQuery "ZqryAppendNewWeeklyActuals", acViewNormal, acEdit
    DoCmd.SetWarnings True

End Function

Code:
Function macMissing()
On Error GoTo macMissing_Err

    DoCmd.OpenQuery "qryMissing in188", acViewNormal, acReadOnly

End Function
 
in macmissing, test the count first

if dcount("*",qrymissingin188")>0 then
DoCmd.OpenQuery "qryMissing in188", acViewNormal, acReadOnly
else
call maccombine
end if


as your functions don't return values its more normal to declare them as subs, but this won't stop the code running
 
Thank You that did it.
 

Users who are viewing this thread

Back
Top Bottom