I want to hiding and unhiding the database window and a few other things...

K

Kelvin Beaton

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
 
O

OldPro

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
 
K

Klatuu

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
 
O

OldPro

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



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- Hide quoted text -

- Show quoted text -

That will only work in Access97; there isn't an MsysObjects in later
versions. It is true my version throws an error, but it does handle
it and correctly returns false (0) when it happens.
 
K

Kelvin Beaton

Thanks to both of you for the input!!!

Kelvin


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



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- Hide quoted text -

- Show quoted text -

That will only work in Access97; there isn't an MsysObjects in later
versions. It is true my version throws an error, but it does handle
it and correctly returns false (0) when it happens.
 
D

Douglas J. Steele

MSysObjects exists in other versions of Access as well.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



That will only work in Access97; there isn't an MsysObjects in later
versions. It is true my version throws an error, but it does handle
it and correctly returns false (0) when it happens.
 
K

Kelvin Beaton

Hi Dave

I have a question.
I'm using this code in my close form event.
++++++++++++++++++++++++++++++++++
Private Sub Form_Close()
DoCmd.SetWarnings False
DoCmd.DeleteObject acTable, "PSI_Denials-Cleaned"
DoCmd.CopyObject "", "PSI_Denials-Cleaned", acTable,
"PSI_Denials-CleanOriginal"
DoCmd.DeleteObject acTable, "PSI_Denials"
DoCmd.SetWarnings True
End Sub
++++++++++++++++++++++++++++++++++
How can I incorporate your code and my code?
I tries a couple of options I could think of, but no luck...

Thanks for your time!

Kelvin

Klatuu said:
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:
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
 
K

Kelvin Beaton

If "DoCmd.SelectObject acTable, , True" displayes the database window,
shouldn't "DoCmd.SelectObject acTable, , False" hide it.

I get a Run-time error 2493 that says "This action requires an Object Name
argument"

What is the name of the database window?

Thanks

Kelvin
 
K

Klatuu

Not correct. I am on 2003 and I have been using it since 2000.
It is a hidden table, but it is there.
--
Dave Hargis, Microsoft Access MVP


OldPro said:
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!


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- Hide quoted text -

- Show quoted text -

That will only work in Access97; there isn't an MsysObjects in later
versions. It is true my version throws an error, but it does handle
it and correctly returns false (0) when it happens.
 
K

Klatuu

See example below.
Also, I suggest you put the code for the function in a standard module so
your entire app has access to it. I have a module that is for nothing but
those useful litte functions.
--
Dave Hargis, Microsoft Access MVP


Kelvin Beaton said:
Hi Dave

I have a question.
I'm using this code in my close form event.
++++++++++++++++++++++++++++++++++
Private Sub Form_Close()
DoCmd.SetWarnings False
If TableExists("PSI-Denials-Cleaned") Then
DoCmd.DeleteObject acTable, "PSI_Denials-Cleaned"
DoCmd.CopyObject "", "PSI_Denials-Cleaned", acTable,
"PSI_Denials-CleanOriginal"
End If
If TableExists("PSI-Denials-Cleaned") Then
DoCmd.DeleteObject acTable, "PSI_Denials" End If
DoCmd.SetWarnings True
End Sub
++++++++++++++++++++++++++++++++++
How can I incorporate your code and my code?
I tries a couple of options I could think of, but no luck...

Thanks for your time!

Kelvin

Klatuu said:
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
 
K

Kelvin Beaton

Thanks Dave

Actually I was trying to do that but can't see how to call the public
function from the form event...

My module is called "mod_TableExists" and the Public Function is
"TableExists"
What do I put in the Event?
I tried the Expression builds and it gave me this "TableExists
(«strTableName») «Expr» TableExists («strTableName»)" but that doesn't seem
to work either.

Thanks for your help!

Kelvin

Klatuu said:
See example below.
Also, I suggest you put the code for the function in a standard module so
your entire app has access to it. I have a module that is for nothing but
those useful litte functions.
--
Dave Hargis, Microsoft Access MVP


Kelvin Beaton said:
Hi Dave

I have a question.
I'm using this code in my close form event.
++++++++++++++++++++++++++++++++++
Private Sub Form_Close()
DoCmd.SetWarnings False
If TableExists("PSI-Denials-Cleaned") Then
DoCmd.DeleteObject acTable, "PSI_Denials-Cleaned"
DoCmd.CopyObject "", "PSI_Denials-Cleaned", acTable,
"PSI_Denials-CleanOriginal"
End If
If TableExists("PSI-Denials-Cleaned") Then
DoCmd.DeleteObject acTable, "PSI_Denials" End If
DoCmd.SetWarnings True
End Sub
++++++++++++++++++++++++++++++++++
How can I incorporate your code and my code?
I tries a couple of options I could think of, but no luck...

Thanks for your time!

Kelvin

Klatuu said:
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


:

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
 
O

OldPro

Thanks Dave

Actually I was trying to do that but can't see how to call the public
function from the form event...

My module is called "mod_TableExists" and the Public Function is
"TableExists"
What do I put in the Event?
I tried the Expression builds and it gave me this "TableExists
(«strTableName») «Expr» TableExists («strTableName»)" but that doesn't seem
to work either.

Thanks for your help!

Kelvin




See example below.
Also, I suggest you put the code for the function in a standard module so
your entire app has access to it. I have a module that is for nothing but
those useful litte functions.
Hi Dave
I have a question.
I'm using this code in my close form event.
++++++++++++++++++++++++++++++++++
Private Sub Form_Close()
DoCmd.SetWarnings False
If TableExists("PSI-Denials-Cleaned") Then
DoCmd.DeleteObject acTable, "PSI_Denials-Cleaned"
DoCmd.CopyObject "", "PSI_Denials-Cleaned", acTable,
"PSI_Denials-CleanOriginal"
End If
If TableExists("PSI-Denials-Cleaned") Then
DoCmd.DeleteObject acTable, "PSI_Denials" End If
DoCmd.SetWarnings True
End Sub
++++++++++++++++++++++++++++++++++
How can I incorporate your code and my code?
I tries a couple of options I could think of, but no luck...
Thanks for your time!
Kelvin
If the table does not exist, that will throw an error 3265. Here isa
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
:
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- Hide quoted text -

- Show quoted text -

Call it like any other function, i.e.

If TableExists(strTableName) then
' Do something...
Endif

Make sure it is declared as Public.
 
O

OldPro

Not correct. I am on 2003 and I have been using it since 2000.
It is a hidden table, but it is there.
--
Dave Hargis, Microsoft Access MVP



OldPro said:
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
:
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- Hide quoted text -
- Show quoted text -
That will only work in Access97; there isn't an MsysObjects in later
versions. It is true my version throws an error, but it does handle
it and correctly returns false (0) when it happens.- Hide quoted text -

- Show quoted text -

Good to know. I was under the impression that Access got rid of the
msys tables after 97.
 
K

Klatuu

The code for the function goes in a module. You call it from your code as I
described in my previous post.
Again:

If TableExists("MyTableName") Then
Docmd.DeleteObject, acTable, "MyTableName"
End If
--
Dave Hargis, Microsoft Access MVP


Kelvin Beaton said:
Thanks Dave

Actually I was trying to do that but can't see how to call the public
function from the form event...

My module is called "mod_TableExists" and the Public Function is
"TableExists"
What do I put in the Event?
I tried the Expression builds and it gave me this "TableExists
(«strTableName») «Expr» TableExists («strTableName»)" but that doesn't seem
to work either.

Thanks for your help!

Kelvin

Klatuu said:
See example below.
Also, I suggest you put the code for the function in a standard module so
your entire app has access to it. I have a module that is for nothing but
those useful litte functions.
--
Dave Hargis, Microsoft Access MVP


Kelvin Beaton said:
Hi Dave

I have a question.
I'm using this code in my close form event.
++++++++++++++++++++++++++++++++++
Private Sub Form_Close()
DoCmd.SetWarnings False
If TableExists("PSI-Denials-Cleaned") Then
DoCmd.DeleteObject acTable, "PSI_Denials-Cleaned"
DoCmd.CopyObject "", "PSI_Denials-Cleaned", acTable,
"PSI_Denials-CleanOriginal"
End If
If TableExists("PSI-Denials-Cleaned") Then
DoCmd.DeleteObject acTable, "PSI_Denials" End If
DoCmd.SetWarnings True
End Sub
++++++++++++++++++++++++++++++++++
How can I incorporate your code and my code?
I tries a couple of options I could think of, but no luck...

Thanks for your time!

Kelvin

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


:

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
 
J

James A. Fortune

OldPro said:
Not correct. I am on 2003 and I have been using it since 2000.
It is a hidden table, but it is there.
--
Dave Hargis, Microsoft Access MVP



OldPro said:
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
:

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!


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- Hide quoted text -
- Show quoted text -
That will only work in Access97; there isn't an MsysObjects in later
versions. It is true my version throws an error, but it does handle
it and correctly returns false (0) when it happens.- Hide quoted text -

- Show quoted text -


Good to know. I was under the impression that Access got rid of the
msys tables after 97.

The following function doesn't rely on undocumented, potentially
volatile system tables and doesn't rely on error handling either:

Public Function IsTable(strTableName As String) As Boolean
Dim MyDB As DAO.Database
Dim docTable As Document
Dim ctnr As Container
Dim boolFound As Boolean

boolFound = False
Set MyDB = CurrentDb
For Each ctnr In MyDB.Containers
If ctnr.Name = "Tables" Then
For Each docTable In ctnr.Documents
If docTable.Name = strTableName Then
boolFound = True
Exit For
End If
Next docTable
Exit For
End If
Next ctnr
Set MyDB = Nothing
IsTable = boolFound
End Function

James A. Fortune
(e-mail address removed)

Note: Many of my postings have been selectively deleted from Google,
including some of the best ones. I may soon have to drastically limit
posting to newsgroups altogether to prevent such Gerrymandering of ideas.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top