If the table does not exist, that will throw an error 3265. Here is a
function I put together that does check for the existance of a table:
'---------------------------------------------------------------------------------------
' Procedure : TableExists
' DateTime : 8/15/2004 08:17
' Author : Dave Hargis
' Purpose : Tests for the presence of a table
'---------------------------------------------------------------------------------------
'
Public Function TableExists(strTableName As String) As Boolean
On Error GoTo TableExists_Error
TableExists = Not IsNull(DLookup("[Name]", "MsysObjects ", _
"[Type] In (1,4,6) And [Name] ='" & strTableName & "'"))
TableExists_Exit:
Exit Function
TableExists_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure TableExists of Module modUtilities"
GoTo TableExists_Exit
End Function
--
Dave Hargis, Microsoft Access MVP
OldPro said:
On Aug 9, 2:41 pm, "Kelvin Beaton" <kelvin dot beaton at
mccsa dot c o m> wrote:
This code hides the database window,
Docmd.SelectObject acTable, , True
Docmd.RunCommand acCmdWindowHide
so what displays the database window?
I also want to display and hide "full menus" using VBA.
Also when the form closes, I have it deleting a table.
DoCmd.DeleteObject acTable, "PSI_Denials"
How can I check that the table exists?
If it doesn't exist, the it shouldn't try and delete the table, if it
does
exist, it should delete it....
Any help would be appreciated!
Thanks
Kelvin
This code displays the database window:
Docmd.SelectObject acTable, , True
To hide the menu, use the following code:
CommandBars("Menu Bar").Enabled = False
Or create one of your own and assign it to the menu
Me.MenuBar = "Advanced"
CommandBars("Advanced").Enabled = True
CommandBars("Advanced").Visible = True
To check if a table exists:
Function TableExists(strTableName As String) As Boolean
On Error Resume Next
TableExists = IsObject(CurrentDb.TableDefs(strTableName))
End Function