472,142 Members | 1,298 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,142 software developers and data experts.

MSysObjects - Can U modify The Contents???

132 100+
I have a query that uses msysobjects to obtain the names of every report contained in a database. With that, I populate a listbox. The problem is, I guess at one time I created a couple of reports that I have since deleted. However, looks like they are stored in the msysobjects as temp files.....So when I run the app, the listbox contains 4 temp files....how do I get rid of the temp files???? I am working around it by excluding anything that starts with ~TMP as seen in the SQL below.....but how can I get to the MSysObjects and delete those temp files???

SELECT msysobjects.Name
FROM msysobjects
WHERE (((msysobjects.Name) Not Like "~Tmp*") AND ((msysobjects.Type)=-32764))
ORDER BY msysobjects.Name;
Aug 29 '07 #1
3 6833
1,356 Expert 1GB
As a long time MS Access user i would suggest leaving the system tables alone and use the reports collection.

Here is a snipit straight out of the help file. Hope it helps.

Expand|Select|Wrap|Line Numbers
  1. Sub AllReports()
  2.     Dim obj As AccessObject, dbs As Object
  3.     Set dbs = Application.CurrentProject
  4.        For Each obj In dbs.AllReports
  5.             ' Print name of obj.
  6.             Debug.Print obj.Name    
  7.     Next obj
  8. End Sub
Aug 29 '07 #2
3,532 Expert 2GB
All tables that start with MSys are Read-only so, no, you can't do anything except look at them. Access is a pack rat and tends to kept everything in the attic, so to speak! That's why people run into the 750 controls/form limit with large/long standing apps. No one has that many controls on a single form, but once it's been on a form, even if it's deleted later, Access still counts it toward the limit.

My only suggestion would be to try the old open a new, blank db and import everything into it routine and see if that eleminates the temp tables. BTW, Access only has one file, the MDB or MDE file that holds everything! Everything else are objects!

Linq ;0)>
Aug 29 '07 #3
1,356 Expert 1GB
After rereading your post I though I would dig up a routine I have been working on for filling a listbox with my reports. It isn't as clean as I would like yet but hopefully you might find some use for it. In the list box I set the rowsourcetype to GetReports I don't enter anything for the row source. In my case I dont want to view all reports only certain ones so I precede those with SHW and I am set. If you would like all reports remove that if statement and you should be fine.

Expand|Select|Wrap|Line Numbers
  1. Function GetReports(Fld As Control, id As Variant, row As Variant, col As Variant, Code As Variant) As Variant
  2.   Static dbs() As String, Entries As Integer
  3.   Dim ReturnVal As Variant
  4.   Dim con As Container
  5.   Dim db As Database
  6.   Dim doc As Document
  7.   Set db = CurrentDb
  8.     ReturnVal = Null
  9.     Select Case Code
  10.         Case acLBInitialize
  11.             Entries = 0
  12.   Set con = db.Containers("Reports")
  13.     ReDim dbs(con.Documents.Count)
  14.     For Each doc In con.Documents
  15.         Set doc = con.Documents(doc.Name)
  16.         doc.Properties.Refresh
  17.         'The Following restricts my records to the ones preceding the letters SHW
  18.         If Left(doc.Name, 3) = "SHW" Then
  19.                  dbs(Entries) = Right(doc.Name, Len(doc.Name) - 3) ' doc.Container                                    'doc.Properties("Caption")
  20.             Entries = Entries + 1
  21.         End If
  22.     Next doc
  23.                 ReturnVal = Entries
  24.         Case acLBOpen
  25.             ReturnVal = Timer
  26.         Case acLBGetRowCount
  27.             ReturnVal = Entries
  28.         Case acLBGetColumnCount
  29.             ReturnVal = 1
  30.         Case acLBGetColumnWidth
  31.             ReturnVal = -1
  32.         Case acLBGetValue
  33.             ReturnVal = dbs(row)
  34. Case acLBEnd
  35.             Erase dbs
  36.     End Select
  37.     GetReports = ReturnVal
  38.     End Function

If you have any questions or comments let me know.
Aug 29 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Anon | last post: by
6 posts views Thread by pierre.bru | last post: by
reply views Thread by Frank Thiel | last post: by
2 posts views Thread by Simon Radford via AccessMonster.com | last post: by
28 posts views Thread by Charles Sullivan | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.