I would like to know how to make a Command Button automatically delete 2 tables. Extra credit if I can have an "Are You Sure? kind of deal inside the command button too.
I have a month routine where by I import a table from another Office of ours. The table imports as tblCustInfo1 into the HDQ Access 2010 file. I have a routine that makes a new table off of this one. It is called TomCustInfo. When my work is done, I want to automatically delete tblCustInfo1 and TomCustInfo.
I tried something from a 2003 tek-tips article. but I get an error.
The following is on the ON CLICK line.
Private Sub cmd8910_Click()
Dim Db As DAO.Database
Dim tbl As DAO.TableDef
Set Db = CurrentDb()
For Each tbl In Db.TableDefs
If tbl.Name = "TomCustInfo" Then
DoCmd.DeleteObject acTable, "TomCustInfo"
Else
End If
Next
For Each tbl In Db.TableDefs
If tbl.Name = "tblCustInfo1" Then
DoCmd.DeleteObject acTable, "TblCustInfo1"
Else
End If
Next
End Sub
I have a month routine where by I import a table from another Office of ours. The table imports as tblCustInfo1 into the HDQ Access 2010 file. I have a routine that makes a new table off of this one. It is called TomCustInfo. When my work is done, I want to automatically delete tblCustInfo1 and TomCustInfo.
I tried something from a 2003 tek-tips article. but I get an error.
The following is on the ON CLICK line.
Private Sub cmd8910_Click()
Dim Db As DAO.Database
Dim tbl As DAO.TableDef
Set Db = CurrentDb()
For Each tbl In Db.TableDefs
If tbl.Name = "TomCustInfo" Then
DoCmd.DeleteObject acTable, "TomCustInfo"
Else
End If
Next
For Each tbl In Db.TableDefs
If tbl.Name = "tblCustInfo1" Then
DoCmd.DeleteObject acTable, "TblCustInfo1"
Else
End If
Next
End Sub