Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / February 2005

Tip: Looking for answers? Try searching our database.

modify modules

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bret - 25 Feb 2005 23:09 GMT
I would like my VBA code to modify VBA code?
Can this be done?

I have this Public constant string:
Public Const cODBCConnectStr =
"ODBC;DSN=CA-SQL01-DEV;Description=CA-SQL01-DEV;UID=;DATABASE=FRED;Trusted_Connection=Yes"

I would like code to change the string for example to:
Public Const cODBCConnectStr =
"ODBC;DSN=CA-SQL01-DEV;Description=CA-SQL01-DEV;UID=;DATABASE=MARY;Trusted_Connection=Yes"

All I did was change the database from FRED to MARY.

I already have different constants that I just comment on or off as many
developers do.  I also use a table to store the constant string but I would
like code to change code.  

thanks for any help...
Marshall Barton - 26 Feb 2005 01:13 GMT
>I would like my VBA code to modify VBA code?
>Can this be done?
[quoted text clipped - 12 lines]
>developers do.  I also use a table to store the constant string but I would
>like code to change code.

You do NOT want to be modifying VBA code on the fly.  That
would be a heavy duty operation that would greatly increase
your program's vulnerability to corruption.

Since a Constant is constant, it's a bit of an oxymoron to
talk about changing it.  I suggest that you find another way
to accomplish this activity.

How about this?
Public Const cODBCConnectStrA =
"ODBC;DSN=CA-SQL01-DEV;Description=CA-SQL01-DEV;UID=;DATABASE="
Public Const cODBCConnectStrB = ";Trusted_Connection=Yes"
Dim sConnect As String
sConnect  = cODBCConnectStrA & strDBName & cODBCConnectStrB

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.