bengalliboy
MIS
I got the following problem. I have a function that drops the table when I start my project. IF I don't close the project and try to run the same function, it does not see the table and thus, does not drop it. I tried, refresh, save the database, save the table and so forth before exiting the function.... but no luck... What am I doing wrong? TIA --
Function DropTable(ByVal sTableName As String) As Boolean
'Function: DropTable
' Purpose: Drops a table in the current database, if the
' table is found in the tabldefs collection.
Dim db As Database
Set db = DBEngine(0)(0)
' Application.Save
RunCommand acCmdSave
If TableExists(sTableName) Then
db.Execute "Drop Table" & sTableName
End If
DropTable = True
End Function
' Purpose: Determines if a table name is found in the
' Current database's tabledefs collection.
'
'
Function TableExists(ByVal sTableName As String) As Boolean
Dim db As Database, i As Integer
Set db = DBEngine(0)(0)
For i = 0 To db.TableDefs.Count - 1
If "[" & db.TableDefs(i).Name & "]" = sTableName Then
TableExists = True
Exit For
End If
Next
End Function
It look like it does not see the table next time@
Function DropTable(ByVal sTableName As String) As Boolean
'Function: DropTable
' Purpose: Drops a table in the current database, if the
' table is found in the tabldefs collection.
Dim db As Database
Set db = DBEngine(0)(0)
' Application.Save
RunCommand acCmdSave
If TableExists(sTableName) Then
db.Execute "Drop Table" & sTableName
End If
DropTable = True
End Function
' Purpose: Determines if a table name is found in the
' Current database's tabledefs collection.
'
'
Function TableExists(ByVal sTableName As String) As Boolean
Dim db As Database, i As Integer
Set db = DBEngine(0)(0)
For i = 0 To db.TableDefs.Count - 1
If "[" & db.TableDefs(i).Name & "]" = sTableName Then
TableExists = True
Exit For
End If
Next
End Function
It look like it does not see the table next time@