Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2003
    Posts
    104

    Unanswered: File Access From Within Access?

    Hi All,

    I was just wondering how I can Back Up the Database back end file before making any changes. For this to happen I will need something like this (I bolded the things i need)

    Code:
    Public Function BackUpDBBE
       IF EXIST DB_BE_BK.MDB
           DELETE DB_BE_BK.MDB
       END IF
        
       COPY DB_BE.MDB DB_BE_BK.MDB
    
    end function

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    try this

    Code:
    Public Function FileExist(FileName) As Boolean
    On Error GoTo FileExistEH
    Dim FileNameReturned As String
    FileExist = False
    FileNameReturned = Dir(FileName)
    If Len(FileNameReturned) > 0 Then
        FileExist = True
    End If
    Exit Function
    FileExistEH:
    End Function

    so
    if FileExist(path&filename) then

    else

    end if

    look in the help

    Kill [path&filename
    Filecopy fromfile , tofile
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  3. #3
    Join Date
    Nov 2003
    Posts
    104
    Quote Originally Posted by myle
    try this

    Code:
    Public Function FileExist(FileName) As Boolean
    On Error GoTo FileExistEH
    Dim FileNameReturned As String
    FileExist = False
    FileNameReturned = Dir(FileName)
    If Len(FileNameReturned) > 0 Then
        FileExist = True
    End If
    Exit Function
    FileExistEH:
    End Function

    so
    if FileExist(path&filename) then

    else

    end if

    look in the help

    Kill [path&filename
    Filecopy fromfile , tofile
    Oh Wow. Very Cool. Thanx for the help. This should do the trick.

    Do I have permission to use the function you gave me as is or should I re write it? If so, What is your name / URL so I cna give you credit for it?

  4. #4
    Join Date
    Nov 2003
    Posts
    104

    How do you find localdir?

    How can I find out the local directory? The db file could be anywhere from Z:\MyDB to A:\niceDb, etc....

    I need a way to find the path to the database file at run time. How cna this be done?

    Also, Do I have permission to use the function posted above? If so how should I credit it?

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Application.CurrentProject.Path


    Are you doing some versioning or something?

  6. #6
    Join Date
    Nov 2003
    Posts
    104
    Quote Originally Posted by Teddy
    Application.CurrentProject.Path


    Are you doing some versioning or something?
    thanx. I also managed to find this code:

    File Path code

  7. #7
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Also, depending on your version of access, you may want to use the filesystemobject instead. It has built in stuff to do what you want.

    eg:

    Set fsO = CreateObject("ScriptingFileSystemObject")

    If fsO.FileExists("yourpathhere") Then
    Stuff




    It also supports the other actions you're looking for..

    fsO.DeleteFile

    etc

  8. #8
    Join Date
    Nov 2003
    Posts
    104

    kewl 8-)

    Quote Originally Posted by Teddy
    Also, depending on your version of access, you may want to use the filesystemobject instead. It has built in stuff to do what you want.

    eg:

    Set fsO = CreateObject("ScriptingFileSystemObject")

    If fsO.FileExists("yourpathhere") Then
    Stuff




    It also supports the other actions you're looking for..

    fsO.DeleteFile

    etc

    Cool. Thanx for all your help Teddy 8-)

  9. #9
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    Quote Originally Posted by shassouneh
    Oh Wow. Very Cool. Thanx for the help. This should do the trick.

    Do I have permission to use the function you gave me as is or should I re write it? If so, What is your name / URL so I cna give you credit for it?
    Do what you like to it Its

    It the First Function I Wrote about 8Year ago

    Would Like to See it Get Beater
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

Posting Permissions

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