Tips Forum Logo
Tips Forum Home PageSpacerVisit Microsoft Knowledge BaseMAUG Home PageMAUG Russian Home Page

Расширение Syscmd для компиляции и сохранения модулей
Extended solution for "USING SYSCMD TO SAVE AND COMPILE MODULES"

Applies to: Access 97


'***** CODE START

Function SaveAndCompile() As Boolean
'An easy way to save and compile an application's modules is to include
'the SysCmd() function in an existing procedure (or create a new one).
'Source: http://www.arimsoft.ru/msaccess/

SysCmd 504, 16483

'Added by Dejan Mladenovic 24 Nov 1999:
'SysCmd 504, 16483 fails if compile error(s) are encountered during
compilation
'For example, function TestCompile has no syntax errors - Access lets you
write it
'without any warnings. If you try menu command Debug/CompileAllModules you
will get
'message Compile error: method or data member not found.
'Unfortunately, SysCmd simply fails to compile/save without any messages
'To deal with situations like this, I have added few things to the original
function:
'1. Declared function As Boolean
' The function Returns FALSE any errors encountered in compilation
process
' The function returns TRUE if compilation was successful
' Msgbox is added to warn user of any problems.
' Since SysCmd does not point to the error directly, user is advised to
do manual compilation
' in order to locate the error
' If preferred, Else part of MsgBox may be skipped

' ****** This addition by no means makes original function less valuable.
All credit for brilliant idea
' ****** goes to the author of the original function.

'This will check if SysCmd 504, 16483 was successful:
SaveAndCompile = Application.IsCompiled

'Notify user about results of the attempt to compile/save
If Not IsCompiled Then
MsgBox "Compilation process failed due to non-syntax errors in source
code!" & vbCr _
& "Please use menu command Debug /Compile And Save All Modules to find
the error!"
Else
MsgBox "Successfully compiled and saved all modules!"
End If
End Function

'Function with error:
Function TestCompile()
Dim rs As Recordset
rs.Description = 3 'This is an error, although syntax is OK
End Function

'***** CODE END

From  Dejan Mladenovic , Entry Date 25.11.1999



Microsoft Access Solutions

Written and designed by
Alex Dybenko
Send us your comments
Last Update: 2007-10-15
Copyright © 1998-2007 by MAUG

Alex & Access