What is acTable as a AcDataTransferType after DoCmd.TransferSpreadsheet?

Viewed 37

First day at a job and I had to took someones code over and in one of the first functions I have this :

If ExistTable("S_NEW") Then DoCmd.DeleteObject acTable, "S_NEW"
  DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "S_NEW", _
      tmpPATH & Dir(tmpPATH & "S2_*.xlsm "), True, "DF_GRID_1"
DoEvents
  
If ExistTable("FCT_NEW") Then DoCmd.DeleteObject acTable, "FCT_NEW"
  DoCmd.TransferSpreadsheet acTable, acSpreadsheetTypeExcel9, "FCT_NEW", _
      tmpPATH & Dir(tmpPATH & "Fct*.xlsx "), True
DoEvents

The first 'if' looks normal, we delete a table and import new data from an excel. But the second 'if' has an acTable as AcDataTransferType which is following the documentation not a choice.. Keep in mind that this person wrote this part of code a very long time ago.

Is it just a simple import ?

2 Answers

That's a plain old mistype.

The first argument to DoCmd.TransferSpreadsheet is a AcDataTransferType enumeration, while acTable is an AcObjectType enumeration

acTable corresponds to 0, and acImport corresponds to 0, so it functions as if it was acImport. That means there are no functional consequences.

It looks like that is a syntax error, but it still works!!!

The FIRST value or parameter of docmd.Transferspreadsheet is suppose to be one of these 3 choices:

enter image description here

So that is a syntax mistake. But, the code STILL worked and works, since

from above, the first value is a "1" or "0" or "2"

This:

enter image description here

But, it is a typo-o in code. And it should be this:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "FCT_NEW", _
  tmpPATH & Dir(tmpPATH & "Fct*.xlsx "), True

so, the "incorrect" constant of acTable was used, but it still looks to work since

acTable is 0
acImport is 0
Related