Results 1 to 2 of 2
  1. #1
    SteveApa is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    84

    set variable at compile

    Hi All.

    I want to change a connect string based on 32 or 64 bit at compile time. I am getting invalid outside procedure... How do I do this?
    Code:
    Option Compare Database
    Option Explicit
    
    
    Global Const DENODO_SERVER_32BIT_CONNECTION_STRING = "DSN=DenodoODBC_PROD_32Bit;BLA BLA BLA"
    Global Const DENODO_SERVER_64BIT_CONNECTION_STRING = "DSN=DenodoODBC_PROD_64Bit;BLA BLA BLA"
    Global CONNECTION_STRING_SET_AT_COMPILE
    
    
    #If VBA7 And Win64 Then
         Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
        CONNECTION_STRING_SET_AT_COMPILE = DENODO_SERVER_64BIT_CONNECTION_STRING
    #Else
         Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
        CONNECTION_STRING_SET_AT_COMPILE = DENODO_SERVER_32BIT_CONNECTION_STRING
    #End If
    
    
    
    
    Public Function System_Startup_Check()
    Dim findstring As String
    etc...
    Thanks
    Steve

  2. #2
    SteveApa is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    84
    Looks like this worked...
    Code:
    Option Compare Database
    Option Explicit
    
    
    Global Const DENODO_SERVER_32BIT_CONNECTION_STRING = "DSN=DenodoODBC_PROD_32Bit;BLA BLA BLA"
    Global Const DENODO_SERVER_64BIT_CONNECTION_STRING = "DSN=DenodoODBC_PROD_64Bit;BLA BLA BLA"
    
    
    #If VBA7 And Win64 Then
         Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
        Global Const CONNECTION_STRING_SET_AT_COMPILE = DENODO_SERVER_64BIT_CONNECTION_STRING
    #Else
         Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
        Global Const CONNECTION_STRING_SET_AT_COMPILE = DENODO_SERVER_32BIT_CONNECTION_STRING
    #End If
    
    
    
    
    Public Function System_Startup_Check()
    Dim findstring As String
    Dim answer As Variant

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Compile error "variable not defined"
    By CHEECO in forum Access
    Replies: 11
    Last Post: 03-30-2016, 05:39 PM
  2. Replies: 0
    Last Post: 08-10-2011, 11:59 AM
  3. Compile error: Variable not defined
    By HarryScofs in forum Access
    Replies: 8
    Last Post: 07-25-2011, 09:06 AM
  4. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  5. Replies: 23
    Last Post: 03-26-2009, 06:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums