deleting a table variable (1 Viewer)

token_remedie

Registered User.
Local time
Today, 16:55
Joined
Jul 7, 2011
Messages
78
Hey lovers,

I need a kick in the right direction here, trying to delete (or atm just print to msgbox) a variable table name to get rid of any import errors I might get - they wont be important anyway.
it cycles through everything sweet but it wants to delete everything....
Any ideas?


Code:
 Dim tblDef As TableDef
     
    On Error Resume Next
   For Each tblDef In CurrentDb.TableDefs
If InStr(1, tbleDef.Name = "*" & "$A:ZZImportErrors") > 0 Then
   DoCmd.SelectObject acTable, tblDef.Name, True
   DoCme.PrintOut
   MsgBox tblDef.Name
   
   'DoCmd.DeleteObject acTable, tblDef.Name
   Beep
   End If
   Next tblDef
 

jdraw

Super Moderator
Staff member
Local time
Today, 02:55
Joined
Jan 23, 2006
Messages
15,423
What exactly are you trying to accomplish?
In your sample code, you have an extra e in
tbleDef.Name
 

token_remedie

Registered User.
Local time
Today, 16:55
Joined
Jul 7, 2011
Messages
78
oh I'm such an idiot! that's all it was thanks bro :)
 

jdraw

Super Moderator
Staff member
Local time
Today, 02:55
Joined
Jan 23, 2006
Messages
15,423
No, that's not it.
Here some code that will work to find ImportError type tables, but what do you really want to do with these tables?

Sub ChkImportErrors()

Dim tblDef As DAO.TableDef

On Error Resume Next
For Each tblDef In CurrentDb.TableDefs
If tblDef.name Like "*" & "ImportErrors" & "*" Then
DoCmd.SelectObject acTable, tblDef.name, True

MsgBox tblDef.name

'DoCmd.DeleteObject acTable, tblDef.Name
Beep
End If
Next tblDef
End Sub
 

token_remedie

Registered User.
Local time
Today, 16:55
Joined
Jul 7, 2011
Messages
78
that code works perfectly though
and I'm just deleting import error tables cos this stupid spreadsheet import imports a bunch of pointless crap with it
 

jdraw

Super Moderator
Staff member
Local time
Today, 02:55
Joined
Jan 23, 2006
Messages
15,423
The import errors are Errors. These indicate something isn't right -- field value wasn't imported. If the fields are important, you may have to adjust the data before importing.
If the fields are not important , then why import them (put them thru the import process)?
 

token_remedie

Registered User.
Local time
Today, 16:55
Joined
Jul 7, 2011
Messages
78
im importing a workbook and they just come with it into a temp import table and then an append query is run after that.

this now isn't working though:
Code:
DoCmd.RunSQL "INSERT INTO Transactions ( [Asset Number], LOCATION SELECT Master.[Asset Number], Master.LOCATION FROM redisttable INNER JOIN Master ON redisttable.[Asset Number] = Master.[Asset Number] WHERE (((Master.[Asset Number]) Is Not Null) AND (([redisttable].[NEW LOCATION]<>[Master].[Location])=True));"

but it runs if i run it as a query from inside access, but even if i say docmd.openquery and then run that query it doesn't work. Any idea what's going on there?
 

Users who are viewing this thread

Top Bottom