473,763 Members | 2,930 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to change conditional compiler constants using VBA?

I use conditional compiler constants, set through the VBA IDE in
Tools, <projectname> Properties, that I refer to throughout my code to
control which code is used during development, and which during
production. Usually, this only wraps code used to control quitting
the whole app versus just shutting a form, but it can also control
many other things.

However, as part of the build before delivering an update, I have to
remember to change the CC constants, as well as run code to set menu
and command bars for all the forms and reports, remove default project
properties to inhibit user access, recompile, then build a .MDE ready
to deliver.

I'd really like to automate the build, and the one step I can't crack
is setting the CC constant. No, I don't want to set them inline in
the code, nor by using them in a command line in the shortcut to run
the app.

Any ideas?

TIA

Andrew
Nov 12 '05
13 6108
You can make an mde by selecting from the menu, or by using
the syscmd, or by using SendKeys. And you MIGHT be able to
automate the actual menu item, using the menu object:
infinitely better than SendKeys, and that would enable you
to use the CCC's

I got the syscmd constant from the newsgroups (microsoft.publ ic
..access.module sdaovba): now I pass it on to you :~) I think
that Dan Haught (FMS) is credited with the first documentation
of Syscmd 603. He got it from one of the Microsoft Access
Wizards or from examination of the exe/dll entry points.

Regarding Conditional Compile: It works slightly differently
in A2K than in A97, but after compilation it is much more stable
than using a flag! At least when you are debugging, you know
which branch you are in! Not like a variable, accidentally
cleared during debugging by hitting 'end' on an error message.

And if you use a database property or table value, make sure
there is no code that will accidentally clear it if a transient
variable has the wrong value!
(david)

"Andrew" <an************ **@webster.org> wrote in message
news:LG******** **********@news-server.bigpond. net.au...
Ah, that's a useful command.

No, I'd not got as far as scripting the 'Make .MDE'. The steps that I take as standard are:
0. Update version information using a hidden local table and hidden form,
that then exports a version history text file to include in the set-up
1. run procedure to apply custom toolbars/menubars to forms and reports
(never use macros...uuggh! )
2. run procedure to switch off all database properties that allow the user
to get behind the scenes
3. manually change the CC constant(s)
4. recompile (occasionally I'll precede the whole shebang with a command
line decompile as well to clean out the file)
5. manually run 'Make .mde'

After the 'Make .mde' the app reopens now paying attention to the new CC
constants, and behaving as it should in production.

All the routines are run using an AutoKeys shortcut that calls a single
wrapper routine that starts with a message box to allow you to toggle things on or off, and passes this on to the other routines. This allows me to get back in to the mdb to carry on with the next round of work.

The whole lot then gets pulled together with any supporting files, usually
using Inno setup (or the dread P & D wizard for runtime installations until I can figure out an Inno script for the runtime files). Since it's the ..mde is delivered, of course there's not a load that the user can do should the
stumble across the AutoKeys shortcut, and the message encourages them to
cancel anyhow. The worst that could happen is that they might manage to
break into code, and for the user base I'm dealing with, that's not a
threat!

I've written a small VB app that wraps up the decompile process, and I was
thinking it might be possible to write another to wrap up the entire build
process. So the first step would be to work out how to change the CC
constants, then recompile, then 'Make .mde' all from outside. It would be a very handy tool if I can pull it off.

Where did you come across the syscmd 603? Do you know of any other
undocumented syscmd tricks?

Here's me asking for all your secrets - sorry! Still, if you don't ask...

All the best,

Andrew

"david epsom dot com dot au" <david@epsomdot comdotau> wrote in message
news:40******** *************** @news.syd.swift dsl.com.au...
appobj.syscmd 603 "sfile1", "sfile2"

is one of the ways of making an MDE from an MDB.

it does not require that you have the mdb as the current
database, which is probably why it looses the conditional
compile constants.

Are you scripting the 'make mde' phase of your build?
If so, which method are you using?

(david)
"Hopeful" <Li**@in.hope > wrote in message
news:7H******** **********@news-server.bigpond. net.au...
Hi David,

syscmd 603? I know syscmd acSysCmdRuntime (which = 6).

This is running under Access 2k, A2k runtime, and AXP. The .MDE seems to
be
handling the CCs no problem, as long as I remember to recompile after
setting them.

Andrew

"david epsom dot com dot au" <david@epsomdot comdotau> wrote in message
news:40******** *************** @news.syd.swift dsl.com.au...
> > properties to inhibit user access, recompile, then build a .MDE
ready > > to deliver.
>
> > I'd really like to automate the build, and the one step I can't crack > > is setting the CC constant. No, I don't want to set them inline in >
> My experience was that MDE's could not see CC constants defined
> as project properties in the IDE when the build was scripted using
> syscmd 603. Have you tried this? Which version of Access are you
> using?
>
> (david)
>
> =============== =============== ===========
> "Andrew" <an************ **************@ bigpond.com> wrote in message
> news:cb******** *************** **@posting.goog le.com...
> > I use conditional compiler constants, set through the VBA IDE in
> > Tools, <projectname> Properties, that I refer to throughout my code to
> > control which code is used during development, and which during
> > production. Usually, this only wraps code used to control
quitting > > the whole app versus just shutting a form, but it can also control
> > many other things.
> >
> > However, as part of the build before delivering an update, I have to > > remember to change the CC constants, as well as run code to set menu > > and command bars for all the forms and reports, remove default

project > > properties to inhibit user access, recompile, then build a .MDE ready > > to deliver.
> >
> > I'd really like to automate the build, and the one step I can't crack > > is setting the CC constant. No, I don't want to set them inline in > > the code, nor by using them in a command line in the shortcut to run > > the app.
> >
> > Any ideas?
> >
> > TIA
> >
> > Andrew
>
>



Nov 12 '05 #11
Well I did a bit of poking around the web and found the following
(attribution within quote)
############### ##############
Thanks to Jacques Soudan of www.troisj.com for this compilation of
undocumented constants for the SysCmd function:

SysCmd(7) 'Detects the Access VERSION number

For Access 97:

SysCmd 603, PathMdb, PathMde 'convert MDB -> MDE
SysCmd 602, PathMdb, PathMdb 'compact DB
SysCmd 555 'create MSysIMEX... tables
SysCmd(504, 16483) 'save and compile code
SysCmd(504, 16484) 'save code without compiling
SysCmd(501, i) 'list of references, i = 0, 1, ... n
SysCmd(500) 'count of references

For Access 2000+:

SysCmd 603, PathMdb, PathMde 'convert MDB -> MDE
SysCmd 602, PathMdb, PathMdb 'compact DB
'You must use in this case following method, example:
Dim accApp As Access.Applicat ion
Set accApp = New Access.Applicat ion
accApp.SysCmd 603, PathMdb, PathMde
accApp.SysCmd 602, PathMdb, PathMdb
Set accApp = Nothing
SysCmd(605, 0) 'convert DB to previous version
SysCmd(605, "C:\Database97. mdb") 'convert DB to previous version
SysCmd(607,"C:\ Project1.adp") 'convert DB to ADP project
SysCmd(608, i) '60 tips about Access programming for i=0, 1, ... 60
SysCmd(710, 68486165) 'set Polish keyboard (if installed)
SysCmd(710, 67699721) 'set US keyboard
SysCmd(710, 68748313) 'set Russian keyboard
SysCmd(710, 67634184) 'set Greek keyboard
SysCmd(710, ...) 'set other country keyboard
SysCmd(710,1) 'set next installed keyboard
SysCmd(710,0) 'set previous installed keyboard
SysCmd(711) 'return put keyboard currently
SysCmd(714) 'returns TRUE, if any form, report, macro or module is in design
mode
SysCmd(715) 'returns Build number of MSACCESS.EXE file to check Access
version or e.g. which Service Pack is installed.
From Access Extra newsletter October 2003
############### #############

So that's covered my save and compile, and make MDE commands. Now I've just
got to make some time to sit down and write out all the code!

Andrew
"david epsom dot com dot au" <david@epsomdot comdotau> wrote in message
news:40******** *************** @news.syd.swift dsl.com.au...
You can make an mde by selecting from the menu, or by using
the syscmd, or by using SendKeys. And you MIGHT be able to
automate the actual menu item, using the menu object:
infinitely better than SendKeys, and that would enable you
to use the CCC's

I got the syscmd constant from the newsgroups (microsoft.publ ic
.access.modules daovba): now I pass it on to you :~) I think
that Dan Haught (FMS) is credited with the first documentation
of Syscmd 603. He got it from one of the Microsoft Access
Wizards or from examination of the exe/dll entry points.

Regarding Conditional Compile: It works slightly differently
in A2K than in A97, but after compilation it is much more stable
than using a flag! At least when you are debugging, you know
which branch you are in! Not like a variable, accidentally
cleared during debugging by hitting 'end' on an error message.

And if you use a database property or table value, make sure
there is no code that will accidentally clear it if a transient
variable has the wrong value!
(david)

"Andrew" <an************ **@webster.org> wrote in message
news:LG******** **********@news-server.bigpond. net.au...
Ah, that's a useful command.

No, I'd not got as far as scripting the 'Make .MDE'. The steps that I take
as standard are:
0. Update version information using a hidden local table and hidden form,
that then exports a version history text file to include in the set-up
1. run procedure to apply custom toolbars/menubars to forms and reports
(never use macros...uuggh! )
2. run procedure to switch off all database properties that allow the user to get behind the scenes
3. manually change the CC constant(s)
4. recompile (occasionally I'll precede the whole shebang with a command
line decompile as well to clean out the file)
5. manually run 'Make .mde'

After the 'Make .mde' the app reopens now paying attention to the new CC
constants, and behaving as it should in production.

All the routines are run using an AutoKeys shortcut that calls a single
wrapper routine that starts with a message box to allow you to toggle

things
on or off, and passes this on to the other routines. This allows me to

get
back in to the mdb to carry on with the next round of work.

The whole lot then gets pulled together with any supporting files, usually using Inno setup (or the dread P & D wizard for runtime installations

until
I can figure out an Inno script for the runtime files). Since it's the

.mde
is delivered, of course there's not a load that the user can do should the stumble across the AutoKeys shortcut, and the message encourages them to
cancel anyhow. The worst that could happen is that they might manage to
break into code, and for the user base I'm dealing with, that's not a
threat!

I've written a small VB app that wraps up the decompile process, and I was thinking it might be possible to write another to wrap up the entire build process. So the first step would be to work out how to change the CC
constants, then recompile, then 'Make .mde' all from outside. It would be a
very handy tool if I can pull it off.

Where did you come across the syscmd 603? Do you know of any other
undocumented syscmd tricks?

Here's me asking for all your secrets - sorry! Still, if you don't
ask...
All the best,

Andrew

"david epsom dot com dot au" <david@epsomdot comdotau> wrote in message
news:40******** *************** @news.syd.swift dsl.com.au...
appobj.syscmd 603 "sfile1", "sfile2"

is one of the ways of making an MDE from an MDB.

it does not require that you have the mdb as the current
database, which is probably why it looses the conditional
compile constants.

Are you scripting the 'make mde' phase of your build?
If so, which method are you using?

(david)
"Hopeful" <Li**@in.hope > wrote in message
news:7H******** **********@news-server.bigpond. net.au...
> Hi David,
>
> syscmd 603? I know syscmd acSysCmdRuntime (which = 6).
>
> This is running under Access 2k, A2k runtime, and AXP. The .MDE seems
to
be
> handling the CCs no problem, as long as I remember to recompile

after > setting them.
>
> Andrew
>
> "david epsom dot com dot au" <david@epsomdot comdotau> wrote in message > news:40******** *************** @news.syd.swift dsl.com.au...
> > > properties to inhibit user access, recompile, then build a .MDE

ready
> > > to deliver.
> >
> > > I'd really like to automate the build, and the one step I can't

crack
> > > is setting the CC constant. No, I don't want to set them inline

in > >
> > My experience was that MDE's could not see CC constants defined
> > as project properties in the IDE when the build was scripted using
> > syscmd 603. Have you tried this? Which version of Access are you
> > using?
> >
> > (david)
> >
> > =============== =============== ===========
> > "Andrew" <an************ **************@ bigpond.com> wrote in message > > news:cb******** *************** **@posting.goog le.com...
> > > I use conditional compiler constants, set through the VBA IDE in
> > > Tools, <projectname> Properties, that I refer to throughout my code
to
> > > control which code is used during development, and which during
> > > production. Usually, this only wraps code used to control

quitting > > > the whole app versus just shutting a form, but it can also control > > > many other things.
> > >
> > > However, as part of the build before delivering an update, I
have to > > > remember to change the CC constants, as well as run code to set menu > > > and command bars for all the forms and reports, remove default

project
> > > properties to inhibit user access, recompile, then build a .MDE

ready
> > > to deliver.
> > >
> > > I'd really like to automate the build, and the one step I can't

crack
> > > is setting the CC constant. No, I don't want to set them inline in > > > the code, nor by using them in a command line in the shortcut to run > > > the app.
> > >
> > > Any ideas?
> > >
> > > TIA
> > >
> > > Andrew
> >
> >
>
>



Nov 12 '05 #12
"Andrew" <an************ **@webster.org> wrote in
news:le******** **********@news-server.bigpond. net.au:
Well I did a bit of poking around the web and found the following
(attribution within quote)
############### ############## <snips> 'You must use in this case following method, example:
Dim accApp As Access.Applicat ion
Set accApp = New Access.Applicat ion
accApp.SysCmd 603, PathMdb, PathMde
accApp.SysCmd 602, PathMdb, PathMdb
Set accApp = Nothing
From Access Extra newsletter October 2003
############### ############# "david epsom dot com dot au" <david@epsomdot comdotau> wrote in message
news:40******** *************** @news.syd.swift dsl.com.au...
I got the syscmd constant from the newsgroups (microsoft.publ ic
.access.modules daovba): now I pass it on to you :~) I think
that Dan Haught (FMS) is credited with the first documentation
of Syscmd 603. He got it from one of the Microsoft Access
Wizards or from examination of the exe/dll entry points.


Dan posted SysCmd 608 on September 11 1998.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #13
Hi Lyle,

Are you taking gingko? That's a hell of a memory you've got there!

Andrew
"Lyle Fairfield" <Mi************ @Invalid.Com> wrote in message
news:Xn******** ***********@130 .133.1.4...
"Andrew" <an************ **@webster.org> wrote in
news:le******** **********@news-server.bigpond. net.au:
Well I did a bit of poking around the web and found the following
(attribution within quote)
############### ##############

<snips>
'You must use in this case following method, example:
Dim accApp As Access.Applicat ion
Set accApp = New Access.Applicat ion
accApp.SysCmd 603, PathMdb, PathMde
accApp.SysCmd 602, PathMdb, PathMdb
Set accApp = Nothing
From Access Extra newsletter October 2003
############### #############

"david epsom dot com dot au" <david@epsomdot comdotau> wrote in message
news:40******** *************** @news.syd.swift dsl.com.au...
I got the syscmd constant from the newsgroups (microsoft.publ ic
.access.modules daovba): now I pass it on to you :~) I think
that Dan Haught (FMS) is credited with the first documentation
of Syscmd 603. He got it from one of the Microsoft Access
Wizards or from examination of the exe/dll entry points.


Dan posted SysCmd 608 on September 11 1998.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)

Nov 12 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
12633
by: Joseph VanWagoner | last post by:
I want to know how to change the color and look of the <select> border. I wrote: SELECT { BORDER-COLOR:ORANGE; BORDER-STYLE:SOLID; BORDER-SIZE:2PX; } This works for everything, but <select>. Also, How can I change the look of the drop down list button using css?
0
1353
by: Victor Irzak | last post by:
Hello, I want to build two assemblies that use common c# code. I wish to use preprocessor. I defined a constant YABA in "Conditional compilation constants" in the property pages. So the line looks like this: DEBUG;TRACE;YABA Then in my code I have:
1
1244
by: Benne Smith | last post by:
I can't seem to use my normal compiler constants from inside a macro ? It's possible to define NEW constants inside the macro, but this is not what i need. Does anybody know a way to get to them from inside the macro ? Thanks, Benne
10
1381
by: Vladimir Kouznetsov | last post by:
#using <mscorlib.dll> #include <vcclr.h> public __gc class A {}; struct B { void f(A* e); gcroot<A*> e; }; int main() { B().f(new A()); // note that B b; b.f(new A)); works fine return 0;
3
8680
by: Jigar Mehta | last post by:
Hye, I am Jigar Mehta, currently, I am using AfxMessageBox where I need to change the caption of the messagebox using that function only... What I get is, the project name as the caption. I don't want to show my codename of the project to people in my final product, so, I want to change the caption of the messagebox to some different. so, how to do that??? is there any parameter which does this thing ???
1
1306
by: martin | last post by:
Hi, I am having a little trouble defining compiler constants and picking then up in my code. In the configuration manger I defined the constant "Martin" I then set the Project Configuration to "Martin" in the configuration manager.
0
1325
by: Sam Marrocco | last post by:
Is there a way to prevent a conditional compiler directive from "disabling" my #region/End Region statements? If I surround a block of code that contains #region statements with an #if/#EndIf block, when the #if is false, all code folding/formatting dissapears, making the code very unreadable. Any suggestions? -- ================================================================== Sam J. Marrocco Sr. Visual Effects Artist/R&D
2
1153
by: G.Ashok | last post by:
Hi, Is there any option/setting/attribute availble to detect the difference in the value specified for a Ccc on the build tab and used/given in the code? For example: DBEngine="Access" in build tab and #IF DBEngine = "MSAccess" in code. I want to detect the above kind of mistakes in the code. I just want to detect and give a compilation error.
1
9455
by: Marc the Demi-Programmer | last post by:
I am overriding WncProc to make sure my form's location stays within specified parameters. Basically, it has to stay at the top of the screen and not be off to either of the sides. All that works when the form is in its minimal size. However, when the form is maximized using the appropriate button the code that is supposed to set the location is ignored. When the form is switched back to the standard dimensions through the restore...
0
9383
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10140
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9935
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9819
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5268
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3916
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.