Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 10th, 2003, 12:27 PM
Authorized User
 
Join Date: Sep 2003
Location: , , .
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


Reply With Quote
  #2 (permalink)  
Old September 10th, 2003, 01:04 PM
Authorized User
 
Join Date: Jun 2003
Location: Memphis, TN, USA.
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
Reply With Quote
  #3 (permalink)  
Old September 10th, 2003, 02:37 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 10 Times in 9 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

Reply With Quote
  #4 (permalink)  
Old September 10th, 2003, 03:35 PM
Authorized User
 
Join Date: Sep 2003
Location: , , .
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

Reply With Quote
  #5 (permalink)  
Old September 10th, 2003, 03:47 PM
Authorized User
 
Join Date: Sep 2003
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Reply With Quote
  #6 (permalink)  
Old September 10th, 2003, 04:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 10 Times in 9 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


Reply With Quote
  #7 (permalink)  
Old September 10th, 2003, 06:24 PM
Authorized User
 
Join Date: Sep 2003
Location: , , .
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

Reply With Quote
  #8 (permalink)  
Old September 10th, 2003, 09:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 10 Times in 9 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

Reply With Quote
  #9 (permalink)  
Old September 10th, 2003, 09:35 PM
Authorized User
 
Join Date: Sep 2003
Location: , , .
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

Reply With Quote
  #10 (permalink)  
Old September 11th, 2003, 12:47 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 10 Times in 9 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

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 01:38 PM
Dynamic Linked List Boxes ms7ao Classic ASP Databases 2 January 16th, 2004 11:04 AM
SQL , List Boxes/Menu Boxes, DB's Ginzu3 Classic ASP Databases 1 June 30th, 2003 04:07 AM



All times are GMT -4. The time now is 10:30 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.