Results 1 to 5 of 5
  1. #1
    manic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    63

    VBA issue

    Hello All!

    Im having a compile issue and I don't know why, I'm ok with VBA but not a pro, I need a helping hand to see why I'm getting a compile error I'll post the code here maybe someone can tell me where i messed up. the bold red letter gives me the compile error and don't know why.Thanks in advance.

    Function BackUpDb()
    On Error GoTo Err_BackUpDb
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    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
    Set db = CurrentDb()
    Screen.MousePointer = 11
    strFileName = Forms!frmBackUp.BackUpFrom
    sSourcePath = strFileName
    '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)
    sBackupFolder = Forms!frmBackUp.BackUpTo
    sBackupPath = sBackupFolder & "\"
    sBackupFile = sFilePart & "_" & Format(Date, "dd-mm-yyyy") & "-" & Format(Time, "hh-mmAMPM") & sFileExtension
    Call LoadData("Backing Up Database file ............")
    Set fso = New FileSystemObject
    fso.CopyFile sSourcePath, sBackupPath & sBackupFile, True
    Set fso = Nothing
    Set rst = db.OpenRecordset("tblBackUpFile", dbOpenDynaset)
    rst.Edit
    rst!RestorePath = sBackupPath & sBackupFile
    rst!RestoreDate = Now()
    rst.Update
    rst.close

    If IsLoaded("frmBackUp") Then
    Forms!frmBackUp.Requery
    End If
    Pause 2
    Screen.MousePointer = 0
    DoCmd.close acForm, "frmLoading"
    MsgBox "Backup Complete. Backup file is located at: " & Chr(13) & sBackupPath & sBackupFile, vbInformation, " ASSETSonTRACK"
    Exit_BackUpDb:
    Exit Function
    Err_BackUpDb:
    DoCmd.close acForm, "frmLoading"
    Screen.MousePointer = 0
    MsgBox Err.Description, , " Predator Software Backup Utility"
    Resume Exit_BackUpDb
    End Function

    Code#2


    Private Sub btnSaveCSV_Click()
    'Save the source table or query for report as .csv file
    Dim vPath As String, vFilter As String, vReportPath As String
    On Error GoTo ErrorCode

    'Set default file location as C:\ and open SaveAs dialog box for user to save file

    vFilter = ahtAddFilterItem(vFilter, "All Files (*.*)", "*.*") 'define filter string (ALL)
    vFilter = ahtAddFilterItem(vFilter, "CSV Files (*.csv)", "*.csv") 'define filter string (csv)

    vReportPath = Nz(DLookup("CSVFolder", "tblAdmin"), "C:") 'fetch default reports folder
    vPath = ahtCommonFileOpenSave(4108, vReportPath, vFilter, 2, ".csv", Me.lstReports.Column(4) & ".csv", "Save Report as .csv", , False) 'open SaveAs file selector
    If vPath = "" Then Exit Sub 'exit if user cancels save operation

    vReportPath = Left(vPath, InStrRev(vPath, "\")) 'extract pathname
    CurrentDb.Execute "UPDATE tblAdmin SET CSVFolder = '" & vReportPath & "'" 'save new pathname to ReportsFolder field
    If Dir(vPath) <> "" Then
    If MsgBox("WARNING. The report - (" & vPath & ") already exists, do you want to overwrite this file?", vbQuestion + vbYesNo, "Overwrite Confirmation") = vbNo Then Exit Sub
    End If
    DoEvents
    DoCmd.Hourglass True
    DoCmd.TransferText acExportDelim, , Me.lstReports.Column(6), vPath, True 'export query as .csv file to disk


    DoCmd.Hourglass False
    MsgBox "Report saved as " & vPath & ".", vbInformation + vbOKOnly, "Report Saved as .csv File"
    Exit Sub
    ErrorCode:
    DoCmd.Hourglass False
    If Err = 2501 Then Exit Sub 'ignore error if user cancels print
    Beep
    MsgBox Err.Description
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,598
    What are the exact compile error messages?

    IsLoaded is a property unless you have written a custom function for this.

    If Forms!frmBackUp.IsLoaded Then

    As for the aht... function calls. You have the functions in your code module? Review http://access.mvps.org/access/api/api0001.htm
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    manic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    63
    the error is "Ambiguous Name Detected:AhtAddfilter

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,598
    Ambiguous name error usually means there are two procedures in same module with the same name. Or in the case of general modules I guess could be in several modules. Do a search for that string.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    manic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    63
    Got it! Thanks June7, The problem was that I had a butt load of Modules and I didn’t noticed that some of them had the same thing on it and thanks to your Idea of searching that string, I was able to find them a erase them from the dB. Thanks for all the help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. IIF issue
    By mohiahmed in forum Queries
    Replies: 9
    Last Post: 01-22-2012, 01:06 AM
  2. Relationship issue
    By Calgar99 in forum Access
    Replies: 4
    Last Post: 12-14-2011, 07:36 PM
  3. VBA Issue
    By MikeDBMan in forum Access
    Replies: 9
    Last Post: 08-02-2011, 03:59 PM
  4. Issue with Do
    By Petefured in forum Programming
    Replies: 1
    Last Post: 05-25-2011, 09:27 AM
  5. Issue with Relationships
    By Ev0luTioN in forum Database Design
    Replies: 5
    Last Post: 08-06-2010, 11:45 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