Solved

How to make an ADE file by code?

Posted on 2016-11-24
11
34 Views
Last Modified: 2016-12-01
Hi Experts,

Wondering if there is a way to have a button in my app that does the following.

Makes a copy of the current file, then saves that file as an executable (ADE in my case), or perhaps that could be done without making a copy.

The purpose of this is to save the time I have to wait when doing it manually, so this can be running in background while I continue working on my app.
0
Comment
Question by:bfuchs
  • 6
  • 4
11 Comments
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
Not really for the app that your currently in,   But you could write code to do it against another db.  

However with that said,   People usually don't have much luck with this.   Too many things can go wrong with in creating a accede.   And that's not really an executable by the way.   A accde is nothing more than a accdb  with the source code stripped out.

Jim
0
 
LVL 3

Author Comment

by:bfuchs
Comment Utility
Hi Jim,
Not really for the app that your currently in,   But you could write code to do it against another db.
Yes, this was my assumption and therefore I started with the option of copying the file first and doing it to the copy.

However this is also part of the question, if its safe to make a copy of a file while its being used?

Too many things can go wrong with in creating a accede
How about an ADP to an ADE?
Also what exactly can go wrong, I will get an error msg or it will run smoothly and users will later realize problems?

Thanks,
Ben
0
 
LVL 10

Expert Comment

by:LukeChung-FMS
Comment Utility
Are you making an ade from and add? or did you mean accde?

Regardless,  I don't understand the issue. There's no need to make a copy of your current database. Depending on which version of Access you are using, it's either on the menu or under the File, Publish options. It always creates the ade in a new file name and doesn't modify the source database.
0
 
LVL 3

Author Comment

by:bfuchs
Comment Utility
@Luke,

an ade from and add? or did you mean accde?
No, this is an Access ADP project connected to SQL Server 2005 BE. the file (stripped out the code how Jim calls it) has .ADE extension.
See OP
The purpose of this is to save the time I have to wait when doing it manually, so this can be running in background while I continue working on my app
FYI- this is quite large app and it takes a while to compile and save, and since I'm constantly doing it after each app change so users can test it, therefore I'm looking to do it via code in the background..

Thanks,
Ben
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
Comment Utility
<<However this is also part of the question, if its safe to make a copy of a file while its being used?>>

 I have, but technically no because the DB may end up in an inconsistent state.   The file might be changed in several places while your in the process of copying it.   For example, you might pickup a change in table where a new record is added, but not get the index update because you already copied that part of the file.

 Personally for production I would not do it as there is way too much risk.

<<How about an ADP to an ADE?
Also what exactly can go wrong, I will get an error msg or it will run smoothly and users will later realize problems?>>

 Same deal.   Going from a ADP to ADE or accdb to accde is the same process:

1. App is complied
2. Source code is stripped out.
3. Compact and repair is done.

 Typically what goes wrong is the compile part or references are an issue.   There are also various internal constraints in Access that you might run into, such as the table ID limit.   Security is another thing that can get in the way.  The call too to create a ADE is an undocumented one.

But if you want to give it a swing, see:

https://www.experts-exchange.com/questions/28429044/How-do-I-create-an-Access-2010-accde-from-VBA.html#a40050448

Jim.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 3

Author Comment

by:bfuchs
Comment Utility
Hi Jim,

Due to some power outage I got delayed with the response..
Will test it later & let you know.

Thanks,
Ben
0
 
LVL 3

Author Comment

by:bfuchs
Comment Utility
Hi,

OK so far I was able to do so from another file using one of the suggestions mentioned there, however when trying to copy the file itself while its open I get attached error..

Below is the code.

Public Sub MakeADE()
    Dim accApp As Access.Application
    Dim strPathOrigADP As String, strPathSourceADP As String, strPathDestinationADE As String
    strPathOrigADP = Application.CurrentProject.FullName
    strPathSourceADP = Replace(strPathOrigADP, ".ADP", "2.ADP")
    strPathDestinationADE = Replace(strPathSourceADP, "2.ADP", ".ADE")
    Set accApp = New Access.Application
    If Dir(strPathSourceADP) <> "" Then Kill strPathSourceADP
    FileCopy strPathOrigADP, strPathSourceADP
    accApp.SysCmd 603, strPathSourceADP, strPathDestinationADE
    Set accApp = Nothing
End Sub

Open in new window


Thanks,
Ben
untitled.png
0
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
The other DB cannot be opened in exclusive mode.  It must be in shared mode.

Jim.
0
 
LVL 3

Author Comment

by:bfuchs
Comment Utility
Hi,

The reason I'm looking to impliment this is that I can create an ADE while continuing working at the file (programming changes).
While if I open in shared mode, changes cannot be made to the file (I guess).

P.S. I also tried that syscmd directly w/o copying the file and didnt work either.

So far I'm stuck here, unless I try the other suggestions perhaps will have better luck..

Thanks,
Ben
0
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
Ben,

<<So far I'm stuck here, unless I try the other suggestions perhaps will have better luck..>>

 As I said at the start, trying to automate the process is problematic for a number of reasons and most give up on it.

You'll need to write the above as a small utility app, execute that, then start another of instance of Access and continue working on the original file while the other works on creating the accde against the copy.

Jim.
0
 
LVL 3

Author Closing Comment

by:bfuchs
Comment Utility
Thanks
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now