Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code not executing

Status
Not open for further replies.

48Highlander

Technical User
Feb 8, 2004
119
CA
In the following sub, the call to ahtCommonFileOpenSave does not always happen. Does anybody have a clue why this call would not be triggered every time?
Code:
Private Sub CreateWorksheet()

        'Create Excel spreadsheet
        Dim strSQL As String
        Dim qdf As DAO.QueryDef
        Dim strFolderName As String
        Dim strFileFilter As String
        Dim strFileName As String
        Dim lngFlags As Long
        
        'Modify the query or table if FilterDesc is in place
        If Nz(FilterDesc, "") <> "" Then
            strSQL = "Select * From " & strQueryName & " Where " & FilterDesc
            Set qdf = CurrentDb.CreateQueryDef("qryTemp")
            qdf.SQL = strSQL
            strQueryName = "qryTemp"
        End If
        
        strFileName = Me.cboLetterSelect.Column(2) & ".xls"
        strFileFilter = ahtAddFilterItem(strFileFilter, "Excel Files (*.xls)", "*.xls")
        lngFlags = ahtOFN_OVERWRITEPROMPT
        
        strFolderName = ahtCommonFileOpenSave(lngFlags, , strFileFilter, 1, , strFileName, "Specify location and name of file to save")
        
        If Nz(strFolderName, "") = "" Then
            MsgBox "A location was not specified", vbExclamation, "Excel file not created"
            If strQueryName = "qryTemp" Then CurrentDb.QueryDefs.Delete "qryTemp"
            Exit Sub
        End If

        DoCmd.TransferSpreadsheet acExport, , strQueryName, strFolderName
        MsgBox "The following spreadsheet was saved:" & vbCrLf & strFolderName, vbInformation, "Excel file created"
        
        If strQueryName = "qryTemp" Then CurrentDb.QueryDefs.Delete "qryTemp"

End Sub

Bill J
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top