Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2009
    Posts
    2

    Red face Unanswered: Urgent Help for my database Assignment

    Helo.. i have almost completed my Database Assignment (Access 2003) but still i have one module to go that is backup module.. the assignment requirs to take backup of the database at regular interval ..... I have reach through the internet can came up this code

    Dim dbPathName, j As Long, t As Date
    Dim bkupdate, strBatchFlle As String, qot As String
    'On Error GoTo sysBackup_Errqo
    t = Chr$(34)
    bkupdate = Nz(DLookup("bkupdate", "Bkup_ctrl"), 0) ' bkupdate+7 > date() for weekly backup
    If bkupdate = Date Or bkupdate = 0 Then
    Exit Function

    End If
    dbPathName = CurrentDb.Name
    j = InStrRev(dbPathName, "\")
    If j > 0 Then
    strBatchFlle = Left(dbPathName, j)
    strBatchFile = strBatchFlle & "bakup.bat"
    Open strBatchFile For Output As #1
    Print #1, "@Echo off"
    Print #1, "Echo :------------------------- "
    Print #1, "Echo : " & dbPathName
    Print #1, "Echo aily Backup to C:\yasir\"
    Print #1, "Echo :------------------------- "
    Print #1, "Echo : "
    Print #1, "Echo :Please wait... "
    Print #1, "Echo : "
    Print #1, "Copy " & qot & dbPathName & qot & " " & qot & "C:\" & qot
    'add lines here for Back-end database or for other Files
    Close #1 'Copy file
    Call Shell(strBatchFile, vbNormalFocus)
    t = Timer
    Do While Timer <= t + 10 'wait for 10 seconds
    Loop
    DoCmd.SetWarnings False
    DoCmd.RunSQL "UPDATE Bkup_Ctrl SET Bkup_Ctrl.bkupdate = Date(), Bkup_Ctrl.workstation = Environ('COMPUTERNAME');"
    DoCmd.SetWarnings True 'Kill strBatchFile
    End If
    sysBackup_Exit:
    Exit Function
    sysBackup_Err: MsgBox Err.Description, , "sysBackup()"
    Resume sysBackup_Exit
    End Function

    there is two problem in this code and i couldnt solved the probles

    when i run the code a msg saying Type mismatch

    its it the t varivale as date, when i chanege it to String that problem is solved

    and run the bat file
    but it dose not copy the file and another msg popup undefined function Enviornment

    Could anyone pls solve this problem for me
    i need you guys help very much

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    Welcome to the forums.
    Make sure to read Teddy's FAQ by the way.

    Quote Originally Posted by xzyrex
    when i run the code a msg saying Type mismatch

    its it the t varivale as date, when i chanege it to String that problem is solved
    So your dim'ing it as a date, then trying to assign it a string value with the Chr() function, and then trying to assign it a Single value with the Timer() function? No wonder you're having type mismatch problems

    Quite frankly, I'm not sure where you got this code from, but by quick glancing at it, it appears to me to be junk. Try checking out Dev Ashish's Code for copying a database, it might be of use to you. But remember, if this is for an assignment, don't ever plagiarize! Any knowledgeable Access Prof should know about Dev Ashish's work, and plagiarizing is a great way to get kicked out of school.
    Me.Geek = True

Posting Permissions

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