Mr. Browne,
Thank you for your quick response.
I'm getting an append warning box that it could not append 1 field
regardless of the excel doc open or not. This is the column header of column
16 in Excel. The format for F16 is date, so this is expected. If the excel
doc is open, I get an append warning box that it could not append
Upon further testing, I have narrowed the problem. Not sure how code to
include, but here are the steps I'm taking and the results.
Spreadsheet has 16 rows of data. Row 1 is column title, which is deleted
later in my code.
WORKS: run the transfer spreadsheet code with Excel doc not opened. Get
warning box of 1 field not added. All data transfers correctly, except field
f16 on Row 1 (column title on row 1 in column 16). f16 is a date format. So
this is expected.
DOESN’T WORK: when running the transfer spreadsheet, IF the EXCEL doc chosen
is already open, it takes about 5 times longer to import. I get a warning
box that says "fields in 16 records were deleted...â€, this is data in Column
16 (f16 in my table) on 1st tab. F16 is a date column, with the column name
being row 1.
I click ok to the warning message, and it completes the import except Column
16.
I go back to excel, close the excel doc and then get a message box that
appears to be from Excel that notifies me the excel document (name from user
selection above) is now available for editing. If I click OK, it opens an
instance of Excel, but then freezes Excel. Access operates fine.
I thought if I could identify if the Excel doc is open before the transfer
spreadsheet command, I could just avoid all of this....
or Can I open the excel doc as READ ONLY in the transfer spreadsheet command?
Any thoughts would be greatly appreciated.
Here is the code up to the transfer spreadsheet line.
‘**** CODE SAMPLE
Private Sub cmd_Import_MTT_Click()
10 On Error GoTo cmd_Import_MTT_Click_Error
Dim strFilter As String
Dim strInputFileName As String
Dim tempCount As Integer
Dim Response As String
'this will prompt user to select excel file to import
20 strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)",
"*.XLS")
30 strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
40 Me.txt_InputFile = strInputFileName
47 DoCmd.OpenForm "frm_Processing"
48 Forms!frm_Processing.Refresh
49 Forms!frm_Processing.Repaint
50 DoCmd.SetWarnings False
'These tables should already be blank, but just in case...
60 DoCmd.OpenQuery "qry_Clear_temp_Excel_Action_Info"
70 DoCmd.OpenQuery "qry_Clear_temp_Excel_Action_Info_Row"
80 DoCmd.OpenQuery "qry_Clear_temp_Excel_Action_Info-0"
90 DoCmd.OpenQuery "qry_Clear_temp_Excel_Step_Info"
100 DoCmd.OpenQuery "qry_Clear_temp_Excel_Step_Info_Row"
110 DoCmd.OpenQuery "qry_Clear_temp_Excel_Step_Info-0"
120 DoCmd.OpenQuery "qry_Clear_temp_Excel_Requirement_Info"
130 DoCmd.OpenQuery "qry_Clear_temp_Excel_Requirement_Info_Row"
140 DoCmd.OpenQuery "qry_Clear_temp_Excel_Requirement_Info-0"
150 DoCmd.OpenQuery "qry_Clear_temp_tbl_FR_Static"
160 DoCmd.OpenQuery "qry_Clear_temp_tbl_IA_Assigned_to_FR"
170 DoCmd.OpenQuery "qry_Clear_temp_tbl_TR"
171 DoCmd.OpenQuery "qry_Clear_tbl_TD_Upload_Requirements"
172 DoCmd.OpenQuery "qry_Clear_tbl_TD_Upload_Test_Lab"
173 DoCmd.OpenQuery "qry_Clear_tbl_TD_Upload_Test_Plan"
174 DoCmd.SetWarnings True 'temporary for troubleshooting
'MsgBox "Before Transfer"
'add rows from selected spreadsheet Requirement Info tab to
temp_Excel_Requirement_Info-0 table
180 DoCmd.TransferSpreadsheet acImport, ,
"temp_Excel_Requirement_Info-0", strInputFileName, False, "Req & BTS Info$A:Z"
‘many queries below to manipulate the data in the
temp_Excel_Requirement_Info-0 table.
‘***** CODE SAMPLE END *******