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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

filecopy problem 1

Status
Not open for further replies.

Brambojr

Technical User
Oct 26, 2000
73
US
Ok, I have a handful of front ends that we use in a Distribution Center environment. In order to prevent file sharing/corruption issues, I make a copy on the local drive.

Well . . . now our IS department wants to really limit permissions on the c: drives. We can only save things to our "my Docs" and c:\Program Files\(Your company name)\. Filecopy cuts the string at c:\Program and pretends the string ends there.

Does anyone know a way around this? I have googled, hit F1, and searched the Forums all to no avail. I know that eliminating spaces is best, but this is out of my control.

Please help . . .

Brambojr
 
Try putting your filecopy arguments in variables:

strFrom="D:\Database.mdb"
strTo="C:\Program Files\Database.mdb"

FileCopy strFrom,strTo

but I can't see why that should make a difference. Paste the code you have currently & all may become clear.
Alternatively you could use the DOS format. Even long filenames have an 8.3 compatible version so C:\Program Files usualy becomes
c:\program or c:\progr~1

hth

Ben

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
 
Here's the code. The to and froms are all constants set in a module that is also listed below (allows me to make an updater for a new file quickly and easily).

Private Sub Form_Timer()

Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")

DoCmd.RunCommand acCmdAppMaximize

CopyDb:
'Change message displayed to user
Me.lblMsg.Caption = "Updating . . . Please wait"

'Create folders if necessary
For i = 3 To Len(strLocalPath)
If Mid(strLocalPath, i, 1) = "\" And fs.folderexists(Mid(strLocalPath, 1, i - 1)) = False Then
FileSystem.MkDir (Mid(strLocalPath, 1, i - 1))
End If
Next i

'Kill old file if it exists
If fs.FileExists(strLocalPath & strFile) = True Then
FileSystem.Kill (strLocalPath & strFile)
End If

'Create file in specified location
fs.CopyFile (strNetPath & strFile), (strLocalPath & strFile)

GoTo Finish

Finish:

Dim strDB As String
Dim strCmd As String

Dim objSecuredDB As Access.Application
strDB = strLocalPath & strFile
strCmd = SysCmd(acSysCmdAccessDir) & "\MSAccess.exe " _
& strDB & " /wrkgrp " & DBEngine.SystemDB _
& " /user Admin"
Call Shell(strCmd, vbNormalFocus)
DoEvents: DoEvents: DoEvents
Set objSecuredDB = GetObject(strDB)

Application.Quit

Exit Sub

End Sub

Declarations:
Public Const strLocalPath As String = "C:\Program Files\TCS\"
Public Const strNetPath As String = "R:\Access\DC\Master\"
Public Const strFile As String = "IC_COP_FE.mdb"

Public Const strUpdPath As String = "R:\Access\DC\Updaters\"
Public Const strUpdFile As String = "IC_COP_Updtr.mdb"

Public Const strLocalTbl As String = "Version_IC_COP_Local"
Public Const strNetTbl As String = "Version_IC_COP_Master"

Any help would be greatly appreciated.

Brambojr
 
I tried the c:\progra~1 idea and it didn't work.

It was a good idea.

Still looking for ideas.

Brambojr
 
Have you tried this ?
fs.CopyFile strNetPath & strFile, """" & strLocalPath & strFile & """", True

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
I'm not sure why I didn't do this before, I think it didn't work in all OS's we had, but just the simple FileCopy commnad is working great.

I put in as an experiment and I've not had any complaints - well not about that anyhow.

Brambojr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top