ted.martin
Registered User.
- Local time
- Today, 06:37
- Joined
- Sep 24, 2004
- Messages
- 743
Here are the facts:
I am using docmd.outputto to output a table in Excel. I have been asked to have the Excel application Open after the output so have set the Autostart parameter to True.
Everything works fine EXCEPT ....
Later; when I have finished work (and by now the Excel file has been closed) I use Docmd.Quit to close the access database BUT it freezes. If I use Application.Quit instead although that does indeed close access , it leaves the record-locking file open and I cannot re-open the access file as in Task manager MSACCESS is still running. Only when I "End process" can I reopen the file.
This is DEFINITELY something to do with the Excel output as if I revert to Autostart parameter to False, the 'Quit(s)' works fine.
Here is the Code and note the OutputTo is within compound IF statements.
I have tried replacing the Query with an alternate and it still happens. Shortened the file name to test.xls and still access crashes on the Quit. Change the True to False and there are no problems.
Any thoughts would as always be appreciated.
I am using docmd.outputto to output a table in Excel. I have been asked to have the Excel application Open after the output so have set the Autostart parameter to True.
Everything works fine EXCEPT ....
Later; when I have finished work (and by now the Excel file has been closed) I use Docmd.Quit to close the access database BUT it freezes. If I use Application.Quit instead although that does indeed close access , it leaves the record-locking file open and I cannot re-open the access file as in Task manager MSACCESS is still running. Only when I "End process" can I reopen the file.
This is DEFINITELY something to do with the Excel output as if I revert to Autostart parameter to False, the 'Quit(s)' works fine.
Here is the Code and note the OutputTo is within compound IF statements.
Code:
'Now Output the Data
Dim iCount As Integer
iCount = DCount("[ReminderOption]", "Patients", "ReminderOption = TRUE")
If iCount > 0 Then
MsgBox iCount & " Patient Records for Reminders output", vbInformation, "Mail Merge data for " & UCase(strYesNo)
Dim strType As String ' for Log of Reminders
If strYesNo = "Glasses" Then
strType = strYesNo ' for Log of Reminders
If myYesNoResult("Letters Excel Select_Output_Format") = "Letters" Then
Call Reminders("Glasses", "1st")
Else
DoCmd.OutputTo acOutputQuery, "QOR-Reminders GLASSES", "Excel97-Excel2003Workbook(*.xls)", _
"c:\temp\1st_Reminders_Glasses_" & Format([Forms]![FPM-Dates].[txtStartDate], "ddmmyy") & "_" & _
Format([Forms]![FPM-Dates].[txtEndDate], "ddmmyy") & ".xls", True
End If
Else
strType = strYesNo ' for Log of Reminders
If myYesNoResult("Letters Excel Select_Output_Format") = "Letters" Then
Call Reminders("Contact Lens", "1st")
Else
DoCmd.OutputTo acOutputQuery, "QOR-Reminders C-L", "Excel97-Excel2003Workbook(*.xls)", _
"c:\temp\1st_Reminders_CL_" & Format([Forms]![FPM-Dates].[txtStartDate], "ddmmyy") & "_" & _
Format([Forms]![FPM-Dates].[txtEndDate], "ddmmyy") & ".xls", False
End If
End If ' Glasses
DoEvents
Else
MsgBox "No Patients satisfy your Reminders Date range", vbExclamation, "Nothing Output"
End If
DoCmd.Close acForm, "FPM-Dates" ' *****
DoCmd.SetWarnings True
I have tried replacing the Query with an alternate and it still happens. Shortened the file name to test.xls and still access crashes on the Quit. Change the True to False and there are no problems.
Any thoughts would as always be appreciated.
Last edited: