Automate MDE creation? | Needs Regular Fix | | Join Date: Oct 2007 Location: Hull,UK
Posts: 297
| | |
Hi
just wondered if there is code to create an mde, just for ease really (lazyiness)
Cheers
|  | Moderator | | Join Date: Nov 2006 Location: Richmond, Virginia USA
Posts: 3,004
| | | 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)> |  | Expert | | Join Date: Apr 2006 Location: Philadelphia
Posts: 5,226
| | | re: Automate MDE creation? Quote:
Originally Posted by Dan2kx 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: - Private Sub cmdCreateMDE_Click()
-
On Error GoTo Err_cmdCreateMDE
-
Dim AppAccess As Access.Application
-
Set AppAccess = New Access.Application
-
Dim strSourceDB As String
-
Dim strDestinationMDE As String
-
-
'****************** Customize here ******************
-
strSourceDB = "C:\CreateMDE\Test.mdb" '*
-
strDestinationMDE = "C:\CreateMDE\TestMDE.mde" '*
-
'****************************************************
-
-
'Code should go here to see if strDestinationMDE already exists!
-
-
DoCmd.Hourglass True 'Critical!!!
-
-
AppAccess.SysCmd 603, strSourceDB, strDestinationMDE
-
-
DoCmd.Hourglass False
-
-
MsgBox strSourceDB & " has successfully been converted to " & _
-
strDestinationMDE, vbExclamation, "MDE Conversion"
-
-
Exit_cmdCreateMDE:
-
Exit Sub
-
-
Err_cmdCreateMDE:
-
DoCmd.Hourglass False
-
MsgBox Err.Description & vbCrLf & vbCrLf & _
-
strSourceDB & " has not been successfully converted to " & _
-
strDestinationMDE, vbCritical, "MDE Conversion Failure"
-
Resume Exit_cmdCreateMDE
-
End Sub
| | Needs Regular Fix | | Join Date: Oct 2007 Location: Hull,UK
Posts: 297
| | | re: Automate MDE creation?
Does that work with the active DB?
|  | Expert | | Join Date: Apr 2006 Location: Philadelphia
Posts: 5,226
| | | re: Automate MDE creation? Quote:
Originally Posted by Dan2kx 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
| | | 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
|  | Expert | | Join Date: Apr 2006 Location: Philadelphia
Posts: 5,226
| | | 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. - Private Sub cmdCreateMDE_Click()
-
On Error GoTo Err_cmdCreateMDE
-
Dim AppAccess As Access.Application
-
Set AppAccess = New Access.Application
-
Dim strSourceDB As String
-
Dim strDestinationMDE As String
-
-
'*************************** Customize here ***************************
-
strSourceDB = CurrentProject.Path & "\" & CurrentProject.Name
-
strDestinationMDE = Left$(strSourceDB, Len(strSourceDB) - 4) & ".mde"
-
'**********************************************************************
-
-
'Code should go here to see if strDestinationMDE already exists!
-
-
DoCmd.Hourglass True 'Critical!!!
-
-
AppAccess.SysCmd 603, strSourceDB, strDestinationMDE
-
-
DoCmd.Hourglass False
-
-
MsgBox strSourceDB & " has successfully been converted to " & _
-
strDestinationMDE, vbExclamation, "MDE Conversion"
-
-
Exit_cmdCreateMDE:
-
Exit Sub
-
-
Err_cmdCreateMDE:
-
DoCmd.Hourglass False
-
MsgBox Err.Description & vbCrLf & vbCrLf & _
-
strSourceDB & " has not been successfully converted to " & _
-
strDestinationMDE, vbCritical, "MDE Conversion Failure"
-
Resume Exit_cmdCreateMDE
-
End Sub
|  | Moderator | | Join Date: Nov 2006 Location: Richmond, Virginia USA
Posts: 3,004
| | | 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
| | | re: Automate MDE creation? Quote:
Originally Posted by missinglinq 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
| | | 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
| | | 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
| | | re: Automate MDE creation?
I'm good, thanks. But this is a different way than I do it, sounds interesting. Have Fun!
-AJ
|  | Similar Microsoft Access / VBA bytes | | | Forums
Visit our community forums for general discussions and latest on Bytes
/bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,567 network members.
|