Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 10th, 2003, 12:27 PM
Authorized User
 
Join Date: Sep 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic List Boxes

Hi,
Dynamic list boxes is a useful topic and one I got hung up on a
little in attempting to show "AllTables", using the CurrentProject class rather than CurrentData. Although I was successful in listing all the tables for the users, I have system tables like MSysAccessObjects,MSysACEs, MSsyqueries, etc. that I would like to exclude. How can I exclude these from the dynamic list? My coding is:

Private Sub Form_Load()

    Dim objAO As AccessObject
    Dim objCP As Object
    Dim sValues As String

    Set objCP = Application.CurrentData

    For Each objAO In objCP.AllTables
        sValues = sValues & objAO.Name & ";"
    Next objAO

    lstTables.RowSourceType = "Value List"
    lstTables.RowSource = sValues

End Sub

Please, if anyone can help, I would greatly appreciate it.

Thanks,
Sean :D


 
Old September 10th, 2003, 01:04 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

By using a naming convention for your tables, such as tbl in front of all table names, you could use and if/then statement and parse out the table names.

John
 
Old September 10th, 2003, 02:37 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi Sean,

Those AccessObject collections aren't very flexible things. What you're trying to do can be done with a one-liner:

Private Sub Form_Load()

     List1.RowSource = "SELECT Name " & _
                       "FROM MSysObjects " & _
                       "WHERE Type=1 AND Mid([name],1,4)<>'MSys'"

End Sub

This just queries a system table and selects only the user tables.

HTH,

Bob

 
Old September 10th, 2003, 03:35 PM
Authorized User
 
Join Date: Sep 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Bob, thanks! I mean - thank's a lot! That's great. It looks like I went around the issue the long way. I see the logic but am not sure what Type=1 is or what the ,1,4 is for.

You realy helped a lot and I appreciate it.
Thanks again,
Sean

 
Old September 10th, 2003, 03:47 PM
Authorized User
 
Join Date: Sep 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Bob, opened MSysObjects and see it all clear now.
Thanks,
Sean

 
Old September 10th, 2003, 04:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi Sean,

For the values of MSysObjects.Type see:

http://www.perfectparadigm.com/Tip001.html

Mid([name],1,4) means "give me the first four characters of the object name starting at the first character." See the Mid Function in the helpful VBA help file which is accessed from the VBA editor menu (not the "unhelpful" Access help file which is accessed from the Access menu).

Quote:
quote:Bob, opened MSysObjects and see it all clear now.
Not sure what you're telling me here.

Bob


 
Old September 10th, 2003, 06:24 PM
Authorized User
 
Join Date: Sep 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Bob -
Hi, I was saying...
Quote:
quote:opened MSysObjects and see it all clear now.
because I opened the MSysObjects table and saw [name] field where this holds the string of the tables to list excluding if the first 4 characters are 'MSys' and the [type] field = 1. I am a beginning VBA programmer and when I saw this, it was clear as to why the code is written as it is.

I have been getting better at intuitively writing the code, but some things just aren't that easy. I have another posting regarding tickle reports. This is one topic I have not really seen in the Wrox VBA collection.

Many thanks for your help,
Sean

 
Old September 10th, 2003, 09:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi Sean,

I see. I was just a little worried that you had somehow opened up MSysObjects and inadvertantly deleted its contents. I'd recommend leaving your system tables hidden and never open them directly. No reason to. Better to just query them if you want to access their contents. Deleting something could wreck your db.

Select *
From MSysObjects

Bob

 
Old September 10th, 2003, 09:35 PM
Authorized User
 
Join Date: Sep 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Bob, The system tables are protected an I don't think I can delete them. Yet, you're right it's probably not a terrific idea to be opening them. That is one of the reasons I wanted them to be removed from the dynamic list box. Now the users can't inadvertantly open the system tables.

If you have any suggestions on where I should start in developing the scheduling logic for a db, I could definately use some suggestions. I posted "tickle reports"

Thanks,
Sean

 
Old September 11th, 2003, 12:47 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi Sean,

I have a Contacts Management database that is based on one of the sample databases of the same name that shipped with (I think) A2K (maybe 97). This database uses tickler functionality to launch a 'Reminder' form when the db opens to display reminders regarding contact follow-up issues (Action Items). It uses an ocx Calendar control to set the tickler date. The functionality is too involved to post (three forms with a bunch of code are used) but you can download a copy (I think) from the Microsoft downloads site. Just look for a database named 'Contact Management' under the availabe Access downloads.

Bob






Similar Threads
Thread Thread Starter Forum Replies Last Post
LIST BOXES Vision G Access 10 May 27th, 2006 01:45 AM
List Boxes, Help! JeffGirard Access 17 August 22nd, 2005 01:31 PM
Tell about dynamic list boxes shyamprasad Classic ASP Components 3 February 8th, 2005 02:38 PM
Dynamic Linked List Boxes ms7ao Classic ASP Databases 2 January 16th, 2004 12:04 PM
SQL , List Boxes/Menu Boxes, DB's Ginzu3 Classic ASP Databases 1 June 30th, 2003 04:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.