Make MDE via VB

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'd like to add a button on a secure form in my .MDB file to make an .MDE
file from the calling .MDB file. I can't find any VB command for this.
Suggestions? It gets tiresome to publish a new version manually. :)
 
Hi.
I'd like to add a button on a secure form in my .MDB file to make an .MDE
file from the calling .MDB file. I can't find any VB command for this.

You won't find any code suggestions either, because one cannot make an MDE
file via code or macro from the currently open database file. However, one
can close the current database file, then open another one that has a form
with a command button that calls the following sub to create a new MDE file
from the MDB file just closed:

' * * * * Start Code * * * *

Private Sub createMDE()

On Error GoTo ErrHandler

Dim accApp As New Access.Application

accApp.SysCmd 603, "C:\Work\MyDB.mdb", "C:\Work\MyDB.mde"

CleanUp:

accApp.Quit
Set accApp = Nothing

Exit Sub

ErrHandler:

MsgBox "Error in createMDE( )" & vbCrLf & _
"in Utils module." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description

Err.Clear
GoTo CleanUp

End Sub ' createMDE( )

' * * * * End Code * * * *

Please note that this SysCmd is undocumented and unsupported by Microsoft.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. Remember that the first and
best answers are often given to those who have a history of rewarding the
contributors who have taken the time to answer questions correctly.
 
Thanks, Camaro.

I ran this code, substituting my drive/directory names, but nothing appeared
to happen. No error, no .mde file. Any thoughts? I'm using UNC names, and
I removed any existing .mde file also to see if there were problems from this.
 
Hi.
No error, no .mde file.

There will be no error message if it fails for any reason. It just fails
silently.
Any thoughts?

It will fail if the source file doesn't exist or if the source file is open
when the code runs. It may even fail if a new instance of Access is not
created prior to creating the MDE file.

Try this test: create a new MDB file and save it as C:\MyTest.mdb. Then
replace my suggested line of code:

accApp.SysCmd 603, "C:\Work\MyDB.mdb", "C:\Work\MyDB.mde"

with:

accApp.SysCmd 603, "C:\MyTest.mdb", "C:\MyTest.mde"

And then run the createMDE( ) procedure. Does this create the C:\MyTest.mde
file successfully?

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. Remember that the first and
best answers are often given to those who have a history of rewarding the
contributors who have taken the time to answer questions correctly.
 
You're welcome. Glad you got it working. Please consider signing in to the
Online Community and marking my first post as an answer so that others can
quickly find the code when they have the same question, too.

Thanks!

Gunny
 

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

Back
Top