Home > front end >  What is acTable as a AcDataTransferType after DoCmd.TransferSpreadsheet?
What is acTable as a AcDataTransferType after DoCmd.TransferSpreadsheet?

Time:09-02

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 ?

CodePudding user response:

That's a plain old mistype.

The first argument to DoCmd.TransferSpreadsheet is a 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