• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 439
  • Last Modified:

How to start Access minimized when opened in repair mode

We have three databases that are used heavily.  I am trying to write a bat file that will execute when a user logs in to Windows in the startup folder.  Below is the batch code which is working.  The only issue is that the Access opens and repairs it is a full sized window.  I would like it to be minimuzed to prevent must notice by the user.  Any suggestions?
If NOT Exist "\\mv\db\DB1.ldb" "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "\\MV\DB\DB1.mdb" /Repair
 
If NOT Exist "\\mv\db\DB2.ldb" "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "\\MV\DB\DB2.mdb" /Repair
 
If NOT Exist "\\mv\db\DB3.ldb" "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "\\MV\DB\DB3.mdb" /Repair

Open in new window

0
thandel
Asked:
thandel
  • 5
  • 4
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:

You might try the /nostartup        option from the KB article: (http://office.microsoft.com/en-us/access/HP051883001033.aspx):

I'm doing basically the same thing using the Shell command in VBA to Compact, but all I see is Access briefly in the task bar ... and I'm not using /nostartup either.

"Starts Access without displaying the task pane (task pane: A window within an Office application that provides commonly used commands. Its location and small size allow you to use these commands while still working on your files.) (the second dialog box that you see when you start Access)."


On thing ... also note this from the KB article

"/repair        Repairs the Access database that was specified before the /repair option, and then closes Microsoft Access. In Microsoft Access 2000 or later, compact and repair functionality is combined under /compact. The /repair option is supported for backward compatibility."

So, you should just use /compact.

mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
0
 
thandelAuthor Commented:
No difference using /nostartup or /compact.

Anything else I could try?
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!

 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Well, I'm not a batch file guy.  

I used the Shell command and actually I used the ShellWait from here:

http://www.mvps.org/access/api/api0004.htm

And I called it with the optional vbMinimizedNoFocus parameter.

So,  that's probably what is making it work in my case.

So, if you can some how translate that to the batch file ... or ... instead execute some VBA code ... it should work, because it does for me.

I used ShellWait because I am compacting about 20 mdb's in a loop ... and I need to be sure one was done before the next started.

mx
0
 
thandelAuthor Commented:
Can you provide a sampled of your complete code that used vbMinimizedNoFocus?  Was this a script? API? I'm not familar.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Here is an example:

Dim sLwsPath As String
Dim sFile As String

sFile = "DB1.mdb"     ' example
sLwsPath ="C:\SomeFolderName"   ' where DB1.mdb exists


sCmd = Chr(34) & SysCmd(acSysCmdAccessDir) & "Msaccess.exe" & Chr(34) & " " & Chr(34) & sLwsPath & "\" & sFile & Chr(34) & " /COMPACT"
                   
Call ShellWait(sCmd, vbMinimizedNoFocus)

The ShellWait is from the mvps link above.  Create a new vba module ... call it vbaShell (or whatever - just different from the Function name)... and paste in all the code from mvps.

sCmd is the full command line you need to execute - similar to what you have in the batch file.

SysCmd(acSysCmdAccessDir) just gets the directory that Access is installed in - for convenience.

Again ... you will need to run this from something other than a batch file.
0
 
thandelAuthor Commented:
If not running from a batch file that what would I run it in?
0
 
thandelAuthor Commented:
I found the following:

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_22063331.html

However when I use the command: START /min "" "<insert path here>\dbname.mdb"

It doesn't execute with the completed command to compact the .mdb file.

If NOT Exist "\\mv\db\DB1.ldb" start /min "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "\\MV\DB\DB1.mdb" /compact
0
 
thandelAuthor Commented:
Please close no solution offered
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now