Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    renaming destination database (Access 2000)

    can i rename a database with a code taking the next number available?
    I am copying a database with the help of the following function :

    Public Function copydb()
    Dim strSource As String
    Dim strDest As String
    strSource = "C:BEdb1.mdb"
    strDest = "C:BEArchive.mdb"
    FileCopy strSource, strDest
    End Function

    My question is, is it possible the string source for the next
    copy to be db2, db3, etc?
    If it is not possible is it possible with the current date ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: renaming destination database (Access 2000)

    I'm confused - do you want the source database to change, or the destination database? The subject of your post seems to contradict the body.

  3. #3
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: renaming destination database (Access 2000)

    Try
    <pre>Public Function copydb()
    Dim strSource As String
    Dim strDest As String
    Dim i as long
    For i = 1 to someUpperNumber
    strSource = "C:BEdb" & i & ".mdb"
    strDest = "C:BEArchive" & i & ".mdb"
    FileCopy strSource, strDest
    Next i
    End Function
    </pre>

    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

  4. #4
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: renaming destination database (Access 2000)

    My God ! Please do apologize me ! I have confused the lines.The source should be

    strSource = "C:BEdepot..mdb"

    And the destination should be :
    strDest = "C:bearchive.depot1.mdb

    Actually i will call the database depot, and i want in the folder archive to store the depots under different numbers,
    for example depot1,depot2,depot3, etc

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: renaming destination database (Access 2000)

    Try this:

    Sub CopyDb()
    Const strPath = "C:BEArchive"
    Const strSource = "C:BEDepot.mdb"
    Dim strFile As String
    Dim lngNum As Long
    Dim lngMax As Long
    Dim strDest As String

    strFile = Dir(strPath & "Depot*.mdb")
    Do While Not strFile = ""
    lngNum = Val(Mid(strFile, 6, Len(strFile) - 9))
    If lngNum > lngMax Then
    lngMax = lngNum
    End If
    strFile = Dir
    Loop

    strDest = strPath & "Depot" & (lngMax + 1) & ".mdb"
    FileCopy strSource, strDest
    End Sub

  6. #6
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: renaming destination database (Access 2000)

    Thanks Hans.Working flawlessly

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •