Must be over my head / import using transferspreadsheet & dialog *

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Either I'm more inept than I thought, or there's something really really
simple I'm missing (even WITH everyones help here)... I'm kind learning as I
go along and very very new.

I'm using a transferspreadsheet command to import a temporary excel table
into a master list. To get the .xls file i'm using the dialog box (the api,
as per mvps.org/access/api/api0001.htm).... then it goes into a comparison
to see if the data's already in the master and cancels if its dup data.

I thought I had it right (been a LONG process) but now I'm getting the "This
actions requires an object name argument" error.. which I'm struggling with
because the modules all seem to work on there own...

TIA...

(heres' the code...sorry, I know its really sloppy... i'm a noob)

Dim strFilter As String
Dim strInputFileName As String

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave(Filter:=strFilter, OpenFile:=True,
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "strtable",_
strInputFileName, True, "a:v"
DoCmd.Rename "TblTempCap", acTable, strtable

Dim strqry As String
strqry= 'my sql
If Not DataApPended() Then
DoCmd.RunSQL strqry, False
DoCmd.DeleteObject acTable, "TblTempCap"

Else
msg5 = "THAT DATE WAS ALREADY UPDATED!"
MsgBox msg5, vbCritical, "DATA EXISTS"
DoCmd.DeleteObject acTable, "TblTempCap"
Exit Sub
End If

Exit_Toggle0_Click:
Exit Sub

Err_Toggle0_Click:
MsgBox Err.Description
Exit Sub

End Sub

Private Function DataApPended() As Boolean
Dim db As DAO.Database, rst As DAO.Recordset
Set db = DBEngine.Workspaces(0).Databases(0)
Set rst = db.OpenRecordset("SELECT Count(*) As MatchCount " & _
"FROM TblTempCap INNER JOIN tblCAPAllAccounts " & _
"On (TblTempCap.[Todays Date] = tblCAPAllAccounts.[Date
Rpt'd])")
DataApPended = (Nz(rst("MatchCount"), 0) <> 0)
End Function
 
Back
Top