Connecting Tech Pros Worldwide Forums | Help | Site Map

Automate MDE creation?

Needs Regular Fix
 
Join Date: Oct 2007
Location: Hull,UK
Posts: 297
#1: Aug 31 '09
Hi

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

Cheers

missinglinq's Avatar
Moderator
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 3,004
#2: Sep 1 '09

re: Automate MDE creation?


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)>
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,226
#3: Sep 1 '09

re: Automate MDE creation?


Quote:

Originally Posted by Dan2kx View Post

Hi

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

Cheers

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
Needs Regular Fix
 
Join Date: Oct 2007
Location: Hull,UK
Posts: 297
#4: Sep 1 '09

re: Automate MDE creation?


Does that work with the active DB?
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,226
#5: Sep 1 '09

re: Automate MDE creation?


Quote:

Originally Posted by Dan2kx View Post

Does that work with the active DB?

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.
Expert
 
Join Date: Jul 2009
Location: KY
Posts: 253
#6: Sep 1 '09

re: Automate MDE creation?


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
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,226
#7: Sep 1 '09

re: Automate MDE creation?


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
missinglinq's Avatar
Moderator
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 3,004
#8: Sep 1 '09

re: Automate MDE creation?


That would require two or three mouse clicks, and as he said, he's lazy!

Linq ;0)>
Needs Regular Fix
 
Join Date: Oct 2007
Location: Hull,UK
Posts: 297
#9: Sep 1 '09

re: Automate MDE creation?


Quote:

Originally Posted by missinglinq View Post

That would require two or three mouse clicks, and as he said, he's lazy!

Linq ;0)>

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
Expert
 
Join Date: Jul 2009
Location: KY
Posts: 253
#10: Sep 1 '09

re: Automate MDE creation?


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
Needs Regular Fix
 
Join Date: Oct 2007
Location: Hull,UK
Posts: 297
#11: Sep 1 '09

re: Automate MDE creation?


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
Expert
 
Join Date: Jul 2009
Location: KY
Posts: 253
#12: Sep 1 '09

re: Automate MDE creation?


I'm good, thanks. But this is a different way than I do it, sounds interesting. Have Fun!

-AJ
Reply


Similar Microsoft Access / VBA bytes