VBA – Change Conditional Compilation Arguments in Access

VBA is not a scripting language. It compiles. As such, it has compilation arguments, which can be changed through code or manually. In MS Access you may find these here:

VBEditor>Tools>VBA Project>Database Properties:

If you want to use them for some debugging, this is the way to change them through code:

Application.SetOption "Conditional Compilation Arguments","A=4:B=10"

And this is how you get them:

Application.GetOption("Conditional Compilation Arguments")

Once you use them, you can refer to them like this for debugging reasons:

Sub TestMe()

    #If A = 1 Then
        Debug.Print "a is 1"
    #Else
        Debug.Print "a is not 1"
    #End If

End Sub

Cheers!