Solved

Closed prematurely - Still need help with Autoexec

Posted on 2006-06-19
12
327 Views
Last Modified: 2006-11-18
Cross REf: http://www.experts-exchange.com/Databases/MS_Access/Q_21891519.html


My orignial code has me processing the 2nd mdb and then closing it and then zip the update mdb and then 3rd mdb is opened by user for them to save to their pc.

Should I do a filecopy of the original mdb, reopen the copy - rename the autoexec in that copy and then zip it? and How do I deactivate the autoexec in the newly copied mdb - since it will be in the copied version also.

What do you think.

Karen
0
Comment
Question by:Karen Schaefer
  • 5
  • 5
12 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 16937687
Why dont u make a copy of the 2nd mdb

then run that which processes it
then delete the object in that db?

so u always leave your master 2nd mdb, just make a copy and send that?

0
 

Author Comment

by:Karen Schaefer
ID: 16937705
How do I stop the autoexec in the copied version of the mdb - so that I can rename the macro?

Karen
0
 

Author Comment

by:Karen Schaefer
ID: 16937711
Can I send  the code from my 1st mdb to rename a macro in another mdb?

K
0
 

Author Comment

by:Karen Schaefer
ID: 16937746
This what I have come up with so far:

   ShellEx "\\Wabelhdk0215892\Intranet Information Server\CorePlan\Manual PLANIT Forecast For Scrubbing.mdb" ', , , , ,
    FileCopy "\\Wabelhdk0215892\Intranet Information Server\CorePlan\Manual PLANIT Forecast For Scrubbing.mdb", "\\Wabelhdk0215892\Intranet Information Server\CorePlan\TempCopy\Manual PLANIT Forecast For Scrubbing.mdb"
     ShellEx "\\Wabelhdk0215892\Intranet Information Server\CorePlan\TempCopy\Manual PLANIT Forecast For Scrubbing.mdb" ', , , , ,
 
 but the autoexec still exist in the tempcopy of the mdb.  need to deactivate or delete the autoexec from here?

K
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 16937897
This bit of code deletes a object on another DB


    Dim acc As Object
    Dim strFullFilePath As String
   
    Set acc = CreateObject("Access.Application")
   
    acc.OpenCurrentDatabase "C:\EE\mydb3.mdb"
    acc.DoCmd.DeleteObject acMacro, "AutoExec"

    Set acc = Nothing


So u make a copy of your 2nd mdb, then run the autoexec
you then want to delete that autoexec right?
try the above code

I guess if you want to rename it, u could try this

    acc.DoCmd.Rename "NewMacroName", acMacro, "OldMacroName"

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)

 

Author Comment

by:Karen Schaefer
ID: 16937933
is it possible to use a IF statement or Select Case to validate which currentdatabase is open and if not equeal to the original mdb filepath then delete or rename the macro - instead of having to copies of the same mdb.

if so what is the best approach to handle this.

K
0
 

Author Comment

by:Karen Schaefer
ID: 16937973
How do I return the current value (ie. filepath) of active mdb?

K
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 16937974
Not sure what you mean

I thought u have your masters

then make copy of your masters and just delete the object in there
this way you shouldn't need to worry about anything else do you? sorry for sounding confused

Karen, Ive got to go now, hopefully Ive given you something to help you along the way, looks like u still need some help.
If no one else has answered, I will help you tomorrow (if Im still sober! - Im going to the pub to watch England play Sweden)
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 16937979
currentpath is

CurrentProject.Path

to get full path of current db

CurrentProject.Path & "\" & CurrentProject.name
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
ID: 16941014
Can I suggest u place your paths in variables - here it is, hopefully you understand the logic, just add in the missing bits
What Im saying is you create your Masters. These do not have any processing done on them
What u do is make a copy then run processing on these copies and delete/rename macros. Safe thing is the master is left alone.



dim sOriginal as String
dim sCopy as String


sOriginal = "\\Wabelhdk0215892\Intranet Information Server\CorePlan\Manual PLANIT Forecast For Scrubbing.mdb"
sCopy = "\\Wabelhdk0215892\Intranet Information Server\CorePlan\TempCopy\Manual PLANIT Forecast For Scrubbing.mdb"


'Lets take original and make a copy
FileCopy sOriginal, sCopy

'Now run the macro
ShellEx sCopy ', , , , ,

'Now delete the AutoExec Macro in the copy

    Dim acc As Object
    Dim strFullFilePath As String
   
    Set acc = CreateObject("Access.Application")
   
    acc.OpenCurrentDatabase sCopy
    acc.DoCmd.DeleteObject acMacro, "AutoExec"
'or
    acc.DoCmd.Rename "OldAutoExec", acMacro, "AutoExec"

    Set acc = Nothing






But if u want the Master to have the processing done on it
then you have to

1. Run processing on Master
2. Make copy of Master to temp
3. Delete/Rename Macro in Temp
4. Do what you want with Temp


0

Featured Post

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)

Question has a verified solution.

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

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

911 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

19 Experts available now in Live!

Get 1:1 Help Now