[AccessD] Compiler directives

jwcolby jwcolby at colbyconsulting.com
Wed Nov 3 16:39:07 CDT 2010


I like to use the machine name to decide whether it is debug mode.

John W. Colby
www.ColbyConsulting.com

On 11/3/2010 4:18 PM, Jim Dettman wrote:
> Aruthur,
>
>    Personally, I would avoid the compiler directives for this.   Two
> solutions:
>
> 1. A function something like the one below, then with logic like this:
>
>
>     If DebugMode() then
>        strTemplateDir = "C:\SAS\Documents\"
>     Else
>        strTemplateDir = "C:\Documents And Settings\All Users\Documents\"
>     End If
>
>    Note that my "debug mode" is triggered simply by saving a .txt file in the
> directory where the MDB resides.  Flag could be anything though, including
> an VBA constant.
>
> 2. Or a data driven setup where you fetch the value from a Config table:
>
>
> 20        RunReportAsPDF = ""
>
> 30        strPDFPrinter = GetAppConfigValue(AppShortName(), "PDFPrinter",
> ".", ".")
> 40        strPDFProgPath = GetAppConfigValue(AppShortName(), "PDFProgPath",
> ".", ".")
> 50        strPRNFile = GetAppConfigValue(AppShortName(), "PDFPrnFile ", ".",
> ".")
>
>
>      GetAppConfigValue() can fetch the data from anywhere. It doesn't have to
> be a table.  If you want to see the GetAppConfigValue(), I can post that.
>
> Jim.
>
> Function DebugMode() As Integer
>
>          ' Determines if app is running in debug mode.
>          ' Debug mode is set by placing a .txt file
>          ' in the database directory with a name of
>          '<database name>_Debug.txt
>
>          Dim strFileName As String
>          Dim intLen As Integer
>
> 10      On Error GoTo DebugMode_Error
>
> 20      If Nz(gvarDebugMode, "") = "" Then
> 30        On Error GoTo 0
> 40        Err = 0
> 50        strFileName = left(CurrentDb.Name, Len(CurrentDb.Name) - 4)&
> "_Debug.txt"
> 60        intLen = Len(Dir(strFileName))
> 70        If (Not Err And intLen>  0) Then
> 80          gvarDebugMode = True
> 90        Else
> 100         gvarDebugMode = False
> 110       End If
> 120       On Error GoTo DebugMode_Error
> 130     End If
>
> DebugMode_Exit:
> 140     On Error Resume Next
>
> 150     DebugMode = Nz(gvarDebugMode, False)
>
> 160     Exit Function
>
> DebugMode_Error:
> 170     gvarDebugMode = Null
> 180     Resume DebugMode_Exit
>
> End Function
>
>
>
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller
> Sent: Wednesday, November 03, 2010 3:49 PM
> To: Access Developers discussion and problem solving
> Subject: [AccessD] Compiler directives
>
> Sorry to ask for the answer to an old question, folks, but advanced age and
> lack of practice is causing serious memory lapses.
>
>
>
> The central problem is that the client and I run the app in different
> environment, and that this in turn causes different definitions of various
> directory locations, etc.
>
>
>
>> From within a given module, I know how to check for various compile
> options,
> but I cannot recall how to define them in the first place.
>
>
>
> For example, a snippet ...
>
>
>
> <vba>
>
> Dim strTemplateDir as String
>
> #If DEVELOPER Then
>
>        strTemplateDir = "C:\SAS\Documents\"
>
> #Else
>
>        strTemplateDir = "C:\Documents And Settings\All Users\Documents\"
>
> #End If
>
> Dim strFileName as String
>
> strFileName = strTemplateDir&  "MyFile.dotx"
>
> </vba>
>
>
>
> The above sample code is required several times in various modules, so I
> thought that the simplest way was to pass a compile argument DEVELOPER which
> would compile the appropriate lines.
>
>
>
> Perhaps I should add that I am not in search of run-time arguments, but
> rather compile-time arguments. However, if this is not the way to go, then I
> shall be willing to entertain the run-time arguments alternative.
>
> So I want to define DEVELOPER while I'm working at home, but also issue to
> CLIENT a version without this argument, so that when she compiles it, the
> app references her directory structure and not mine.
>
>
>
> To further complicate things, the client in question has a nasty habit of
> revising the Word templates and appending the revision-date to the filename.
> I want to eliminate these complications, perhaps like this:
>
>
>
> Define a constant MyTemplate, with a value such as MyFile_2010-11-02.dotx.
>
> Refer to said constant using #MyTemplate in all the code.
>
> When she or I choose to provide a new version of the template's filename,
> then all that is required is to revise the arguments, e.g. not touch a line
> of code.
>
>
>
> Can anyone prod my failing memory and remind me how to define these?
>
>
>
> I should add that I am developing in A2K7 while the client is running in
> A2K10. I don't know whether this complicates things further.
>
>
>
> TIA,
>
> Arthur



More information about the AccessD mailing list