Page 3 of 3 FirstFirst 123
Results 31 to 43 of 43
  1. #31
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Nope! Neither "/Y" or "/y" will copy without my having to press the "f" key. I still get the prompt to specify "f" for file, "d" for directory. (I guess Windows command code doesn't know how to parse strings?)

  2. #32
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Nope! Neither "/Y" or "/y" make any difference. I still have to enter "f".

    Ooops! hadn't noticed thread had increased to 3 pages.

  3. #33
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Will look later to see what I might have/can find about this; gotta run now

  4. #34
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I just tested a file copy using Microsoft's VBA FileSystemObject. So far it seems to do the job. One has to add Microsoft Scripting Runtime to their Reference, not a big deal. I'll integrate that scheme into my app's code and post back with the results........... hopefully to close out this caper.

  5. #35
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Quote Originally Posted by GraeagleBill View Post
    I just tested a file copy using Microsoft's VBA FileSystemObject. So far it seems to do the job. One has to add Microsoft Scripting Runtime to their Reference, not a big deal. I'll integrate that scheme into my app's code and post back with the results........... hopefully to close out this caper.
    Not true. The backup code I posted in #20 uses FSO and does NOT require any additional references
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #36
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    A mystery to me, as I had looked at your code and concluded the same thing. Yet, when I attempted to compile my app it became obvious that I needed it.

  7. #37
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    HALLELUJAH! Between Micron's & Colin's suggestions I finally got a solution. The snippet of code below gathers what is needed and uses FSO to do the copy. The error handler (not shown) takes care of runtime error 58 if the target file already exists, (XCOPY has a switch for that). You'll notice I take no chances pertaining to an un-reported FSO failure by checking the file lengths after the copy.

    Code:
    Dim FSO As Scripting.FileSystemObject  'Requires a reference to Obj Lib "Microsoft Scripting Runtime.
    
    '*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    '                C R E A T E  A R C H I V E  F I L E  N A M E
    '*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    
    strArchName = Replace(curBackEnd, "\eBud\", "\eBud\DB-Archives\")     'Change the folder
    
    If InStr(strArchName, "(Personal)") > 0 Then
        strArchName = Replace(strArchName, "eBudData(Personal)", "Personal-Data")
    Else
        strArchName = Replace(strArchName, "eBudData(Business)", "Business-Data")
    End If
    
    strFirstDate = Replace(curFirstDate, "/", "-")
    strEndDate = Replace(curEndDate, "/", "-")
    strArchName = Replace(strArchName, ".mdb", "(" & strFirstDate & " To " & strEndDate & ").mdb")
    strArchive = curBackEnd & ";" & strArchName
    
    Set FSO = New Scripting.FileSystemObject
    
    Call FSO.CopyFile(curBackEnd, strArchName, False)
    
    Set FSO = Nothing
    
    If FileLen(curBackEnd) <> FileLen(strArchName) Then
        msgbox "Any additional archiving options are being" & vbnewline & _
               "suppressed, as the size of the DB copy DOES" & vbnewline & _
               "NOT equal that of the original."

  8. #38
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Praise be!

    Now if you compare your code and mine, its obvious why you need the scripting reference.
    You're using early binding whereas my code uses late binding.

    Your code
    Code:
    Dim FSO As Scripting.FileSystemObject  'Requires a reference to Obj Lib "Microsoft Scripting Runtime.
    ...
    Set FSO = New Scripting.FileSystemObject
    My code:
    Code:
    Dim fso As Object 'no reference needed
    ...
    Set fso = CreateObject("Scripting.FileSystemObject")
    Swop the 2 lines and you no longer need the reference (at least not for this code)
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  9. #39
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Swop the 2 lines and you no longer need the reference
    Done! As usual Colin, you're among the best.

    Thanks,
    Bill

  10. #40
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Thanks for your kind words .... Not sure I deserve them though!
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  11. #41
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Sorry I couldn't get back sooner. Been gone out all day and replaced my router when I got home, so have been off line most of the day. Late or not, I try to keep my promises, so what I used is below. I can't swear it will copy an open db because I'm retired a few years now and don't exactly recall the scenario for its use. What you might find useful is the line that gets around the issue of users having different drive letters for the same drive/volume label where the db is accessed from: set MyDir=%~dp0
    The only caveat is that for as written, the bat file has to be in the same location as the db.

    Code:
    rem to copy OSCRbe to backup database
    rem must be run from this folder
    
    cls
    @echo off
    
    rem next line sets directory to current location, 
    rem but uses the assigned drive letter (e.g. F, L, etc.)
    
    set MyDir=%~dp0
    
    rem now use that value by reference
    cd %MyDir%
    
    :CopyFiles
    rem use quotes around paths for cases where uniformed used spaces in path
    
    copy "%MyDir%OSCRbe.mdb" "%MyDir%OSCRbe_Bak.mdb" /y
    
    :quit
    exit
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  12. #42
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    Late to the game but I figured I'd add this link to a procedure I have used in the past to Backup and compact a db.

    http://accessmvp.com/thedbguy/code.php?title=backup

  13. #43
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Hi Moke
    Just to say Brent's code in that link is very similar to the backup and compact code I provided in post #20.
    My version can also handle password protected files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 03-27-2017, 07:48 PM
  2. Replies: 5
    Last Post: 05-27-2013, 09:34 AM
  3. Replies: 1
    Last Post: 11-23-2012, 03:08 PM
  4. Replies: 3
    Last Post: 06-27-2012, 03:21 PM
  5. Replies: 4
    Last Post: 05-21-2012, 08:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums