468,296 Members | 1,313 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,296 developers. It's quick & easy.

Automate MDE creation?

365 100+
Hi

just wondered if there is code to create an mde, just for ease really (lazyiness)

Cheers
Aug 31 '09 #1
11 2682
missinglinq
3,532 Expert 2GB
My guess would be no! And if you could it would be a really bad idea! Too many things can go awry during the creation that require the attention/intervention of the developer.

Linq ;0)>
Aug 31 '09 #2
ADezii
8,799 Expert 8TB
@Dan2kx
Aside from changing the Source and Destinations, use the code exctly as posted:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdCreateMDE_Click()
  2. On Error GoTo Err_cmdCreateMDE
  3. Dim AppAccess As Access.Application
  4. Set AppAccess = New Access.Application
  5. Dim strSourceDB As String
  6. Dim strDestinationMDE As String
  7.  
  8. '****************** Customize here ******************
  9. strSourceDB = "C:\CreateMDE\Test.mdb"              '*
  10. strDestinationMDE = "C:\CreateMDE\TestMDE.mde"     '*
  11. '****************************************************
  12.  
  13. 'Code should go here to see if strDestinationMDE already exists!
  14.  
  15. DoCmd.Hourglass True    'Critical!!!
  16.  
  17. AppAccess.SysCmd 603, strSourceDB, strDestinationMDE
  18.  
  19. DoCmd.Hourglass False
  20.  
  21. MsgBox strSourceDB & " has successfully been converted to " & _
  22.        strDestinationMDE, vbExclamation, "MDE Conversion"
  23.  
  24. Exit_cmdCreateMDE:
  25.   Exit Sub
  26.  
  27. Err_cmdCreateMDE:
  28.   DoCmd.Hourglass False
  29.   MsgBox Err.Description & vbCrLf & vbCrLf & _
  30.          strSourceDB & " has not been successfully converted to " & _
  31.          strDestinationMDE, vbCritical, "MDE Conversion Failure"
  32.     Resume Exit_cmdCreateMDE
  33. End Sub
Sep 1 '09 #3
Dan2kx
365 100+
Does that work with the active DB?
Sep 1 '09 #4
ADezii
8,799 Expert 8TB
@Dan2kx
To be honest with you, I didn't test the code with an Active Database. If you do, I strongly suggest using a Copy and testing with that.
Sep 1 '09 #5
ajalwaysus
266 Expert 100+
In my experience this does not work on the active DB, because creating an MDE requires the DB to compile first which cannot happen while you are running code in VBA. But I must ask, why would you want code to make an MDE in the active DB when you can simply run the Make MDE File... from the tools?

-AJ
Sep 1 '09 #6
ADezii
8,799 Expert 8TB
I modified the code block so that it should create a *.MDE File based on the Active/Current Database with the exact Base Name as the *.MDB and in the same Directory. Although the code indicates success, the actual *.MDE is never created. The reason for this is more than likely that indicated by ajalwaysus in Post #6. I too would like the know the reason why you would even attempt this.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdCreateMDE_Click()
  2. On Error GoTo Err_cmdCreateMDE
  3. Dim AppAccess As Access.Application
  4. Set AppAccess = New Access.Application
  5. Dim strSourceDB As String
  6. Dim strDestinationMDE As String
  7.  
  8. '*************************** Customize here ***************************
  9. strSourceDB = CurrentProject.Path & "\" & CurrentProject.Name
  10. strDestinationMDE = Left$(strSourceDB, Len(strSourceDB) - 4) & ".mde"
  11. '**********************************************************************
  12.  
  13. 'Code should go here to see if strDestinationMDE already exists!
  14.  
  15. DoCmd.Hourglass True    'Critical!!!
  16.  
  17. AppAccess.SysCmd 603, strSourceDB, strDestinationMDE
  18.  
  19. DoCmd.Hourglass False
  20.  
  21. MsgBox strSourceDB & " has successfully been converted to " & _
  22.        strDestinationMDE, vbExclamation, "MDE Conversion"
  23.  
  24. Exit_cmdCreateMDE:
  25.   Exit Sub
  26.  
  27. Err_cmdCreateMDE:
  28.   DoCmd.Hourglass False
  29.   MsgBox Err.Description & vbCrLf & vbCrLf & _
  30.          strSourceDB & " has not been successfully converted to " & _
  31.          strDestinationMDE, vbCritical, "MDE Conversion Failure"
  32.     Resume Exit_cmdCreateMDE
  33. End Sub
Sep 1 '09 #7
missinglinq
3,532 Expert 2GB
That would require two or three mouse clicks, and as he said, he's lazy!

Linq ;0)>
Sep 1 '09 #8
Dan2kx
365 100+
@missinglinq
Yep just wondered if it was theoretically possible, i am a little lazy as mensioned; i have a version number hardcoded into VB (and therefore the MDE) and a version number stored in a linked table so that old versions "know" that they are old and then download the most current version from a server location, in my update code i was considering using the MDE automation... upon your advice i think i should reconsider yes?

Thanks anyways,

Dan
Sep 1 '09 #9
ajalwaysus
266 Expert 100+
I have developed a version controlled databases, like it sounds like you are. When dealing with revision control, you usually need a singular hub (Switchboard) to handle all the version control, so that if what you need is out of date the Switchboard would then get you the most up to date.

Since I have a lot of experience with this, I could provided you with some best practices. But so i don't do the work for you, you can bounce some ideas off me if you wish.

-AJ
Sep 1 '09 #10
Dan2kx
365 100+
I think i have the version control pretty sussed, i only ever have "the newest" release which over writes the previous MDE, so if the active version is out of date (upon DB open) it creates a CMD file, closes, runs the CMD file to pull the new version and wallah!

Pretty simple but it works well, put some of my collegues to shame (who have no version control, or simply a message to alert you to seek the new version)

i can post the code if you are curious?

Thanks again

Dan
Sep 1 '09 #11
ajalwaysus
266 Expert 100+
I'm good, thanks. But this is a different way than I do it, sounds interesting. Have Fun!

-AJ
Sep 1 '09 #12

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Chris via AccessMonster.com | last post: by
2 posts views Thread by Jeremy | last post: by
2 posts views Thread by =?Utf-8?B?QWxleGFuZGVyIFd5a2Vs?= | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.