Results 1 to 3 of 3
  1. #1
    Join Date
    May 2004
    Posts
    37

    Unanswered: Parsefilename Error

    Hi,

    Here is the code that I am using:

    Code:
    Private Sub Command0_Click()
    On Error GoTo Err_Command0
    
    Dim fso As FileSystemObject
    Dim sSourcePath As String
    Dim sBackupPath As String
    Dim sBackupFile As String
    Dim strFileName As String
    Dim sBackupFolder As String
    Dim sFilePart As String
    Dim sFileExtension As String
    
    
    strFileName = "C:\Access.mdb"
    strFileName = FindBackUpFile
    
    sBackupFolder = "C:\"
    
        If Not sBackupFolder = "None Selected" Then
          sBackupPath = sBackupFolder & "\"
        Else
          MsgBox "Operation canceled", vbInformation
        End If
    
    'Establish the file name to allow the same name to be used
    sFilePart = ParseFileName(sSourcePath, 2)
    
    'Establish the extension and make the copy the same. (*.mdb stays *.mdb,*.mde stays *.mde etc)
    sFileExtension = ParseFileName(sSourcePath, 3)
    
    sBackupFile = sFilePart & "_" & txtText0 & sFileExtension
    
    Set fso = New FileSystemObject
    fso.CopyFile sSourcePath, sBackupPath & sBackupFile, True
    Set fso = Nothing
    
    MsgBox "BackUp Complete. Backup file is located at " & sBackupPath & sBackupFile, vbInformation, " DCA Expro BackUp"
    
    Exit_Command0:
        Exit Function
    
    Err_Command0:
        MsgBox Err.Number & " - " & Err.Description, vbCritical, " BackUp Failure"
        Resume Exit_Command0
        
    End Function
    PROBLEM

    When I debug the program, I get the following error message (it highlights Parsefilename (bolded above):

    Sub or function not defined


    What can I do to fix this error?


    Thanks

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    So what is ParseFileName() defined as?

    This code infers it is a function, and the error message is telling you the function or Sub is undefined.

    Its not a function or Sub I'm aware of in VB so it must be a user written one. Perhaps you need to go back to the original source of this code and retrieve the function asw ell.

  3. #3
    Join Date
    Feb 2005
    Posts
    19
    I'd agree with healdem - the code is calling a function ParseFileName (twice) in order to split the filename away from its extension. Then it adds in the underscore plus the contents of txtText0 (could be 'Bak') and saves the new filename. But if the function is not present or defined then you'll get the error message.

Posting Permissions

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