I have some code that exports a table to a users temp drive as an excel file (using transferspreasheet) then, I want the table that was used to be destroyed..
However, after the transferspreadsheet command is run, I get an error saying that the db engine couldn't lock table tblname* because its already in use by another person or process..
It seems almost as if there is some hold on the table created by the transfer spreadsheet code. Any ideas on how to release the hold or otherwise make this work?
Thanks!
*tbl name is variable based on the user input at beginning of form..
If fcn_confirm(str_msg_send_email) = True Then
Call sub_save_req_to_drive 'save to drive and eventually send to email
DoCmd.DeleteObject acTable, str_obj_name_tbl
End If
here is the sub_save_req_to_drive code:
Public Sub sub_save_req_to_drive()
Dim fso, f
Dim str_folder_mod As String 'for creating/deleting folder
Dim str_folder_exp As String 'for export per the transferspreadsheet command, delete won't work with the slash ("/")
Dim frm As Form
Set frm = Forms!frm_pr_proc_sel_req
str_folder_mod = "c:\temp\maaps"
str_folder_exp = "c:\temp\maaps\"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.folderexists(str_folder_mod) Then
fso.deleteFolder (str_folder_mod)
End If
fso.CreateFolder (str_folder_mod)
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, frm.str_obj_name_tbl, str_folder_exp & "pr_" & frm.str_obj_name_tbl, True
However, after the transferspreadsheet command is run, I get an error saying that the db engine couldn't lock table tblname* because its already in use by another person or process..
It seems almost as if there is some hold on the table created by the transfer spreadsheet code. Any ideas on how to release the hold or otherwise make this work?
Thanks!
*tbl name is variable based on the user input at beginning of form..
If fcn_confirm(str_msg_send_email) = True Then
Call sub_save_req_to_drive 'save to drive and eventually send to email
DoCmd.DeleteObject acTable, str_obj_name_tbl
End If
here is the sub_save_req_to_drive code:
Public Sub sub_save_req_to_drive()
Dim fso, f
Dim str_folder_mod As String 'for creating/deleting folder
Dim str_folder_exp As String 'for export per the transferspreadsheet command, delete won't work with the slash ("/")
Dim frm As Form
Set frm = Forms!frm_pr_proc_sel_req
str_folder_mod = "c:\temp\maaps"
str_folder_exp = "c:\temp\maaps\"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.folderexists(str_folder_mod) Then
fso.deleteFolder (str_folder_mod)
End If
fso.CreateFolder (str_folder_mod)
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, frm.str_obj_name_tbl, str_folder_exp & "pr_" & frm.str_obj_name_tbl, True