Connecting Tech Pros Worldwide Forums | Help | Site Map

IsLoaded

JustJim's Avatar
Expert
 
Join Date: May 2007
Location: Bacchus Marsh, Victoria, Australia
Posts: 406
#1: Nov 11 '07
I'm not, though I wish I was!

The un-help files tell me that I can use Isloaded to determine if an object is loaded (duh), but it doesn't tell me what loaded actually means.

I'm trying to determine if a table has been deleted so I think Isloaded is not what I want - is there something like

If Tablename Exists Then....


Thanks in advance

Jim

JustJim's Avatar
Expert
 
Join Date: May 2007
Location: Bacchus Marsh, Victoria, Australia
Posts: 406
#2: Nov 11 '07

re: IsLoaded


Quote:

Originally Posted by JustJim

I'm not, though I wish I was!

The un-help files tell me that I can use Isloaded to determine if an object is loaded (duh), but it doesn't tell me what loaded actually means.

I'm trying to determine if a table has been deleted so I think Isloaded is not what I want - is there something like

If Tablename Exists Then....


Thanks in advance

Jim

Apparently there isn't so I modified this from elsewhere.

Expand|Select|Wrap|Line Numbers
  1. Function CheckExistsAndRename(strCurrentName As String, strNewName As String)
  2. ' check to see if the table exists, if it does then rename it
  3. Dim dbNA As Database
  4. Dim tdf As TableDef
  5. Set dbNA = CurrentDb()
  6.  
  7. For Each tdf In dbNA.TableDefs
  8.     If tdf.Name = strCurrentName Then
  9.         DoCmd.Rename strNewName, acTable, strCurrentName
  10.         Exit Function
  11.     End If  '   tdf.Name = strCurrentName
  12. Next
  13.  
  14. End Function
Jim
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#3: Nov 12 '07

re: IsLoaded


Try this Jim.
Expand|Select|Wrap|Line Numbers
  1. 'TableExists returns true if strName table exists.
  2. Public Function TableExists(strName As String) As Boolean
  3.   TableExists = False
  4.   On Error Resume Next
  5.   TableExists = (CurrentDb.TableDefs(strName).Name = strName)
  6.   On Error GoTo 0
  7. End Function
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#4: Nov 12 '07

re: IsLoaded


BTW If you look up the OnOpen event in the Help system it will describe how objects are loaded - opened - closed - unloaded etc. It has the correct sequence all explained in there. I enclose a short excerpt :)
Quote:

Originally Posted by Help

When you first open a form, the following events occur in this order:

Open ==> Load ==> Resize ==> Activate ==> Current

The Close event occurs after the Unload event, which is triggered after the form is closed but before it is removed from the screen.

When you close a form, the following events occur in this order:

Unload ==> Deactivate ==> Close

JustJim's Avatar
Expert
 
Join Date: May 2007
Location: Bacchus Marsh, Victoria, Australia
Posts: 406
#5: Nov 12 '07

re: IsLoaded


Quote:

Originally Posted by NeoPa

BTW If you look up the OnOpen event in the Help system it will describe how objects are loaded - opened - closed - unloaded etc. It has the correct sequence all explained in there. I enclose a short excerpt :)

Thank you again NeoPa, I suspected very strongly that Loaded was not what I was after. I was quite happy with the solution I nutted out although yours is, as usual, more elegant.

Thanks
Jim
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#6: Nov 12 '07

re: IsLoaded


No worries Jim. Just throwing in some different ideas to chew over :)
Reply


Similar Microsoft Access / VBA bytes