VBA Distinguish Between Running mdb and mde

M

Mike Thomas

In Access 2003 I am developing a new report. While I am developing, the
client needs to run the old report, but I will need to update the program
for other reasons prior to getting their OK for the new report.

In development, I use an mdb file. Their live application is an mde file.

I'd like to run the new report from the mdb file, and the old report from
the mde file

Is there a way I can distinguish in VB code whether the app is running from
an mdb or mde file?

Thanks
Mike Thomas
 
M

Mike Thomas

Never mind - solved this one with the "IsCompiledFile()" function found on
internet.

Mike Thomas
 
A

Albert D.Kallal

Mike Thomas said:
Never mind - solved this one with the "IsCompiledFile()" function found on
internet.

A mdb can be in a compiled state, so the above will not solve your problem.
You SHOULD OFTEN be doing a debug->compile while in the code editor. (that
way, you avoided problems when you try and make the mde).

If you do a debug->compile, then the mdb will also return true for
iscompiledFile.....


A simple solution would be to check the file extension of the current
running file....
eg:

if right(currentProject.Name,3) = "mdb" then
' we are a mdb
else
' we are a mde
end if
 
D

Douglas J. Steele

Albert D.Kallal said:
A mdb can be in a compiled state, so the above will not solve your
problem. You SHOULD OFTEN be doing a debug->compile while in the code
editor. (that way, you avoided problems when you try and make the mde).

If you do a debug->compile, then the mdb will also return true for
iscompiledFile.....


A simple solution would be to check the file extension of the current
running file....
eg:

if right(currentProject.Name,3) = "mdb" then
' we are a mdb
else
' we are a mde
end if

You're right, Albert. That is simple. Perhaps too simple...

You can look for the MDE property of the database object
(CurrentDb.Properties!MDE), which will be the letter "T" in an MDE and which
will not exist in the non-MDE.

Note that looking for a property that doesn't exist will generate an error,
so your code has to be able to handle that error. The following untested
aircode should do it:

Function IsMDE() As Boolean
' Returns True if current db is an MDE,
' False otherwise

On Error Return Next

IsMDE = False
IsMDE = (CurrentDb.Properties!MDE = "T")

End Function
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top