Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening Access with batch file.

Status
Not open for further replies.

lars7

Technical User
Aug 16, 2005
817
GB
Hi Guys,
This is a continuation from the last few posts of thread702-1348773

I should say that I am at home now testing this and my operating system is vista in case that makes a difference:


I have worked out how to create the batch file but I am getting an error message saying "The command line you used to start Microsoft Access contains an option that Microsoft office Accesss doesn't recognize" with this code:

copy \\"C:\Users\Tom and Ruby\Documents\Phase 1 Golden Jubilee.mdb" %temp%\"C:\Users\Tom and Ruby\Documents\Phase 1 Golden Jubilee.mdb" /y
start msaccess.exe %temp%\"C:\Users\Tom and Ruby\Documents\Phase 1 Golden Jubilee.mdb"

does anyone know why.



 
Several syntax issues in your code ...
What do you want to do ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi Ph,

I think these 2 quotes from the original threat sum up what i am looking for:

From JoeAtWork

"One trick we often use is have their shortcuts point to a batch file instead of the front-end. The batch file copies the front-end to their computer then opens it in Access. This makes distributing new versions easier, plus the user always gets a fresh version of the front-end (this is good if you use some temp tables on the front-end - they will not need to compact their own front-end periodically)".


From me


"The database that is in use at the moment has multiple front-end files in C drives, Network drives and the bosses are tired of it as no one is sure which versions are in use and the most up to date. If I can demonstrate to them that this would work I might restore their faith in Access and stop them from looking else where".

I hope this explains it better.

thanks for your reply
 
Something like this ?
COPY "\\ServerName\SharedDir\Phase 1 Golden Jubilee.mdb" "C:\Users\Tom and Ruby\Documents\Phase 1 Golden Jubilee.mdb" /Y
START "C:\Users\Tom and Ruby\Documents\Phase 1 Golden Jubilee.mdb"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi Ph,
I tried you code and after the screen with the information came up a second came with just:

C:\Users\Tom and Ruby>

and is just sitting there.

I got another suggestion from the other thread (I forgot to close and point them here) :~/ at this link:


I downloaded the sample and got it working but trying to fit it into my own project is difficult.

Also on this Web site the author says:

“I recently got involved in a project where they approach this problem from a different slant. The developer created a batch file that copies the latest client from the server to a local folder on the user's machine. The desktop shortcut the user clicks to launch the program opens NOT the Access mdb file, but the batch file. Each time the user clicks the link, a new version is copied down from the server.
REM This batch file copies the XYZ client from \\xyz001\ server
REM ... and starts the program.

COPY \\xyz001\XYZClient.mdb c:\XYZ\XYZClient.mdb
START "MSAccess.exe" c:\XYZ\XYZClient.mdb

EXIT
While this method is much simpler than the one described above, it is a hog for network bandwidth and should be considered only where the client is small and there are few users.”


If this is the case then would this method work for me as the database I have in mind will have around 60 users.
 
This may be of interest for you: faq705-5062

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi Again PH,

I created the 2 modules and changes the file name in 2 places in Module1 modCheckUpdate:

here:

Public Function Checkupdate()

MasterDB = "C:\Users\Tom and Ruby\Documents\Phase 1 Golden Jubilee.mdb"


and here:

Function TypeMismatchFix()

strSource = "C:\Users\Tom and Ruby\Documents\Phase 1 Golden Jubilee.mdb"

and then I

create a form with a button to quit and pasted the code in the on close:

then I

made a copy of this frontend and pasted it onto my desktop.


then I

tested in the front end on the desktop and got an error in the code where I highlighted, the message read "User defined-type not defined":

Private Sub Form_Close()
Dim IniFile As String, OldMMS As String
IniFile = "C:\OldMMS.ini"
[highlight]Dim FileObject As FileSystemObject[/highlight]
Set FileObject = New FileSystemObject
OldMMS = GetINI(IniFile, "OldMMS", "LocationName", "0")

'Gets the path of the oldMMS and deletes it
If FileObject.FileExists(OldMMS) Then
FileObject.DeleteFile OldMMS
End If
If FileObject.FileExists(IniFile) Then
FileObject.DeleteFile IniFile
End If
Call DeleteOld
Set FileObject = Nothing
End Sub


and in Module2 modCopyToINI:

I don't see any file path that needs changing:

I thought I had all the references checked but does it look like I'm missing one.
 
You have to reference the Microsoft Scripting Runtime.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PH,

Sorry I missed that reference, It is closing now but not copying.


I am going away for a short break now but I will be back on Tuesday when I try to sort this out. Thanks as always.
 
Hi PH,

Back from my break and had another look at this but not sure where I am going wrong but did find this:

strDest = DBLocation & "Maintenance Management" & Release & ".mdb"

Maintenance Management was part of the name of the original codes database do I put In the first 2 words of mine?

I’m not sure what DBlocation is but it’s the name of the next function

Function DBLocation() As String
Dim db As Database
Set db = CurrentDb
DBLocation = Left(db.Name, Len(db.Name) - Len(Dir(db.Name)))
Set db = Nothing
End Function


Also I changed the Location name here on the close code but it still did not copy:

From:

Dim IniFile As String, OldMMS As String
IniFile = "C:\OldMMS.ini"
Dim FileObject As FileSystemObject
Set FileObject = New FileSystemObject
[highlight]OldMMS = GetINI(IniFile, "OldMMS", "LocationName", "0")[/highlight]

'Gets the path of the oldMMS and deletes it
If FileObject.FileExists(OldMMS) Then
FileObject.DeleteFile OldMMS
End If
If FileObject.FileExists(IniFile) Then
FileObject.DeleteFile IniFile
End If
Call DeleteOld
Set FileObject = Nothing

To:

Dim IniFile As String, OldMMS As String
IniFile = "C:\OldMMS.ini"
Dim FileObject As FileSystemObject
Set FileObject = New FileSystemObject
[highlight]OldMMS = GetINI(IniFile, "OldMMS", " C:\Users\Tom and Ruby\Documents\Phase 1 Golden Jubilee.mdb
", "0")[/highlight]

'Gets the path of the oldMMS and deletes it
If FileObject.FileExists(OldMMS) Then
FileObject.DeleteFile OldMMS
End If
If FileObject.FileExists(IniFile) Then
FileObject.DeleteFile IniFile
End If
Call DeleteOld
Set FileObject = Nothing

as I said I'm not sure where I have gone wrong but it is just closing with no error messages but it is not copying the other database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top