Solved

Closed prematurely - Still need help with Autoexec

Posted on 2006-06-19
12
331 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

713 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