List Box thing.

TheOx2K

Registered User.
Local time
Today, 07:11
Joined
Feb 19, 2002
Messages
28
Hi all.

I have the following code that shows all tables in my db in a list box the problem that i have is that it also show the system tables. Is there anyway that i can get it not to show these???

Private Sub Form_Open(Cancel As Integer)

z = ""

For Each A In Application.CurrentDb.TableDefs

z = z & " " & A.Name & ";"
Next
List3.RowSource = z


End Sub

Any surgestions would help.
 
I believe the Attributes property of a TableDef includes a value that says a table is a "system object". You can use the constant "dbSystemObject" in an "AND" expression to filter out system objects.

I can't remember all the details.

HTH,
RichM
 
Thank You.

Got it to not show the system tables but would like to know how to get it to show forms now, any ideas?

Private Sub Form_Open(Cancel As Integer)

z = ""
Y = ""

For Each A In Application.CurrentDb.tabledefs
Y = Mid(A.Name, 1, 4)
If Y = "Msys" Then
GoTo x
Else
z = z & " " & A.Name & ";"
x:
End If
Next
List3.RowSource = z

End Sub
 
Constructiv criticism... Really

Best try to avoid GoTo in your programming. It may not seem that big of a deal now but it's sound advice.

Instead of:
Code:
For Each A In Application.CurrentDb.tabledefs 
Y = Mid(A.Name, 1, 4) 
If Y = "Msys" Then 
GoTo x 
Else 
z = z & " " & A.Name & ";" 
x: 
End If 
Next
Try:
Code:
For Each A In Application.CurrentDb.tabledefs 
  If Mid(A.Name, 1, 4) <> "Msys" Then z = z & " " & A.Name & ";" 
Next

HTH,
Jeff
 
Listing Forms

Taylor the AllForms collection to your needs:

AllForms Collection Example

The following example prints the name of each open AccessObject object in the AllForms collection.

Sub AllForms()
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
' Search for open AccessObject objects in AllForms collection.
For Each obj In dbs.AllForms
If obj.IsLoaded = TRUE then
' Print name of obj.
Debug.Print obj.Name
End If
Next obj
End Sub


HTH,
Jeff
 
Thanks that seems to work great. :)

What i am trying to do is set up a form so that i can send current objects as attachments to an e-mail. Now i have a list box that returns the names of the objects that have been selected as attachments to a text box, the problem that i have is that the sendobject command askes for the type of attachment ie table or query. I want to be able to send multiple types of object, can i do this?
 

Users who are viewing this thread

Back
Top Bottom