Acc 2.0: Check existence of a module


Question

I've an application that every time that starts first off all must check if one module exist, if right then erase it. With Acc 2.0 a macro must be used, DOCMD DELETEOBJECT A_MODULE gets an "illegal function call". My question is, how can I test via macro if a particular module exists and if right perform a DELETEOBJECT?

Answer

From: Shamil Salakhetdinov <shamil@marta.darts.spb.ru>
To: ACCESS-L <ACCESS-L@PEACH.EASE.LSOFT.COM>
Subject: Re: Acc 2.0 - How can i delete a module ???
Date: 29 July 1998 22:50

Use this function:

Function TestModulePresence (ByVal vstrModuleName As String) As Integer
    On Error GoTo TestModulePresence_Err
    Dim dbs As Database

    Set dbs = CurrentDB()
    TestModulePresence = (dbs.containers("Modules").documents(vstrModuleName).name = vstrModuleName)
    
TestModulePresence_Exit:
    Set dbs = Nothing
    Exit Function
TestModulePresence_Err:
    Resume TestModulePresence_Exit
End Function

place it in condition field of the macro line with DeleteObject.

HTH,
Shamil


HOME    TOPICS

Copyright © 1998–1999 by Shamil Salakhetdinov.
All rights reserved. Terms of use.

Last updated: June 7, 1999