Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88854

Setting a Constant independent of executed Module

$
0
0

I try to Set a constant which should contain the Connection String for my Database. But the Setup for my macro is so that on the first Sheet in my Excel there are a lot of Buttons. Depending on which Button the user clicks another Module gets executed, but all of them connect to the same DB at some point.

Since I don't want to change the Connection String at many different points it should be done with one Constant.

But I can never tell which Module gets executed an which doesn't.

Therefore I created a new Module which only contains one Line of Code:

Public Const ConnectionString As String = "Driver={MySQL ODBC 8.0 Unicode Driver};Server=localhost;Database=X;User=root;Password=X;"

Unfortunately when a Button is clicked and some Module/Sub gets executed, the Variable "ConnectionString" Contains no Value.

How can I make sure that independent of the called Sub/Module the Constant is set?


Viewing all articles
Browse latest Browse all 88854

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>