Solved

I need a command to save and publish a db as an accde via vba.

Posted on 2012-03-28
8
535 Views
Last Modified: 2012-09-21
I posted this before, but I was hoping someone might have some new ideas.

I need a command to save and publish a db as an accde via vba.

Any thoughts?
0
Comment
Question by:akivashapiro
  • 4
  • 3
8 Comments
 
LVL 57
ID: 37777786
You can try:

SysCmd 603, strPathInputMdb, strPathOutputMde

However it cannot be the current MDB.

Jim.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 37777811
DO you mean you're trying to create an accde from the database you're currently in?
I don't think that is possible.

It is possible to create an mde of a different database in code.
0
 

Author Comment

by:akivashapiro
ID: 38358201
Sorry for the long delay.

I'm using MS Access 2010.

I create a new database and I tried

  SysCmd 603, strPathInputMdb, strPathOutputMde

It does nothing. Also, 603 is not a value listed for SysCmd in the help or drop down enumerations. It may be a hidden command, but it does nothing and generates no error.

I then tried creating a new application instance:

  Dim appAccess As New Access.Application
   appAccess.OpenCurrentDatabase sourceDB$ 'where sourceDB is a different DB from the currentDb
  appAccess.RunCommand acCmdMakeMDEFile

This returns the same error message as when trying to execute acCmdMakeMDEFile on the current db.

Both of you suggest that what I want to do can be accomplished - albeit in a differrent db. If you could attach some code you've tested that would be great and appreciated.

Thanks!
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 57
ID: 38363472
<<It does nothing. Also, 603 is not a value listed for SysCmd in the help or drop down enumerations. It may be a hidden command, but it does nothing and generates no error.>>

 603 is an undocumented call that worked in earlier versions

<<I then tried creating a new application instance:

  Dim appAccess As New Access.Application
>>

  That approach would work, but you don't want to open the database.

Try this instead:

Function GenerateMDEFile(MyPath As String)

    On Error GoTo FailedMDE
   
    Dim NAcc As Access.Application
   
    Set NAcc = CreateObject("Access.Application")
   
    'The following lines simulate accepting the default
    'name, clicking Make MDE, and clicking Save
    SendKeys MyPath & "{Enter}{Enter}"
    SendKeys "{Enter}"
   
    NAcc.DoCmd.RunCommand acCmdMakeMDEFile
   
    Goto Done

FailedMDE:
    msgbox "Failed" & vbcrlf & err.description
Done:
    On Error Resume Next
    Set NAcc = Nothing

End Function


  Note the DB is not opened.  This should work as it is a solution posted by Rocki Roads here on EE.  

  However, I don't know that I'd be trying to automate MDE creation; it's so problematic.   A MDB must be fully compiled, compacted and repaired, and be free from errors in order to convert to a MDE.

  I typically create a brand new DB, import everything, check references, then compile, and follow with a C&R before trying to make a MDE.

  Many in the past have tried to automate that whole process and without much luck (it's simply easier to do it manually).

Jim.
0
 

Author Comment

by:akivashapiro
ID: 38363668
Thanks Jim for the response.

-> In order to do this:
    'The following lines simulate accepting the default
    'name, clicking Make MDE, and clicking Save
    SendKeys MyPath & "{Enter}{Enter}"
    SendKeys "{Enter}"

-> There must be a dialog box to accept the input.

-> This line does not generate a dialog box in Access 2010. I think it did in 2003.
    Set NAcc = CreateObject("Access.Application")

Any other ideas?

Thanks.
0
 
LVL 57
ID: 38367977
<<Any other ideas?>>

 SendKey's sequence is a bit different.  You need Alt/F, then O to bring up the open file dialog.  

  But the other thing that trips this up is the "Enable content" button.  This method is too fragile and the wrong approach.

  Let me see what I can come up with.

Jim.
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 38391380
I'm afraid I've come up with not much.  Best you can do is put the DB in a trusted location and use the sendkey's approach and I have verified that the syscmd 603 call does not work beyond 2003.

Honestly, the MDE creation process is so problematic, I'm not sure why you'd want to automate it anyway.

Jim.
0
 

Author Comment

by:akivashapiro
ID: 38416114
Okay, thanks for trying.
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Ms Access VBA Variables 6 27
Access VBA, adding Progress Bar in code to allow execution. 7 28
update all email addresses SQL 1 23
SQL multicriteria from ONE textbox 32 43
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question