48Highlander
Technical User
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?
Bill J
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