Results 1 to 4 of 4
  1. #1
    J Bhujanga is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2016
    Location
    Colorado
    Posts
    27

    Selecting Tables from VBA code


    I have some VBA code in which I am asking the user to tell it which table has the data that is to be converted according to a process that comes afterward.
    As it is, I use an input box and the user types in the table name and everything proceeds fine and dandily. However, what would be slicker is if the user could click on a table name that exists in the database instead of having to type its name. Can this be accomplished? If so, how is it done?

    If the answer is yes, then can it also allow the user to go to a file window to find a different database from which to specify a table, similar to the way that an Excel sheet lets you import data from an Access by letting you pick a table from within a selected database when you click on the "From Access" icon in the "Data" menu.

    Thanks.

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I have some VBA code in which I am asking the user to tell it which table has the data that is to be converted according to a process that comes afterward.
    As it is, I use an input box and the user types in the table name and everything proceeds fine and dandily. However, what would be slicker is if the user could click on a table name that exists in the database instead of having to type its name. Can this be accomplished? If so, how is it done?
    This is what I use
    Use a combo box or a list box and set the row source to:
    Code:
    SELECT MSysObjects.Name FROM MSysObjects WHERE (((MSysObjects.Type)=1) AND ((Left([Name],4)<>"Msys")=True) AND ((MSysObjects.Flags)=0));
    Returns only local tables- no linked tables.

    Also see http://access.mvps.org/Access/queries/qry0002.htm


    Still thinking about the 2nd question...
    Last edited by ssanfu; 11-29-2016 at 05:31 PM. Reason: added criteria

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    As for your second question ----- getting/selecting a table from a different database ---- you certainly
    could get databases listed, but how exactly would you know what tables exit in any given database.

    You could create a utility that would go through each of your directories, find the databases, then open the database and save the db and tablenames to some known location. Then use that list to resolve the question.
    It would necessitate keeping the list current. So each time you add/delete a table in any database you would have to ensure you run your utility to update the "list".

    Some people create a database as a "dictionary/repository" where each database, each table, each query.... is identified and described. It serves as a "master/authoritative" source for all of your database artifacts.

    Steve Bishop has a new a video (Nov 2016) on importing csv and other delimited files into Access. It goes from simple use of Access tools to the creation of class modules to build a custom dialog for importing files.

    Just some thoughts for consideration.
    Good luck.
    Last edited by orange; 11-30-2016 at 09:48 AM. Reason: spelling

  4. #4
    J Bhujanga is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2016
    Location
    Colorado
    Posts
    27
    Steve,
    Thanks for this reply. It works great and it makes it real easy to filter out tables that they shouldn't be picking by putting a where clause on the 'name' field.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. error when selecting code from a database
    By AAAndy in forum Queries
    Replies: 20
    Last Post: 08-08-2016, 12:26 PM
  2. Replies: 5
    Last Post: 10-13-2015, 02:53 PM
  3. Replies: 9
    Last Post: 07-22-2013, 03:37 PM
  4. Replies: 3
    Last Post: 04-05-2012, 08:33 AM
  5. Selecting the State Code
    By TheBigMaple in forum Queries
    Replies: 1
    Last Post: 03-30-2011, 05:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums