Results 1 to 8 of 8
  1. #1
    jecanne is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    4

    Post Using table data as button captions

    Hi,



    I'm fairly new to using VBA and wanted some help with a procedure. I want the caption for buttons in my Form to be pulled from a record in a table. Additionally, I want the name of the related form or report opened from the button to be pulled from the same record. I've been looking into this and it seems like using DAO is one option, but I'm not familiar with this. I've already go the table set up, that was easy enough. Any help or sample code would be appreciated...thanks!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you going to make all of your forms defined this way? It is certainly do-able but why would you want to?

  3. #3
    jecanne is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    4
    No, just the main menu. I have a main menu form and an associated table. The table is small with just three fields:

    tblMainMenu (ID, Caption, Item)

    The main menu is supposed to pull data from that table's records to populate button captions and know which form/report to open. It's just accessing that data from the table that I don't know how to do...

    I don't want to do this lol. I have an online class and my instructor isn't very helpful. I've read the chapters he asked us to but they don't seem to relate to what he's asking for. I've managed to come up with everything he's asked thus far, but this week has been a struggle.

    Just to clarify, I'm not asking for someone to cheat for me, just a little help.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    In that case, what you are describing is already built into Access. It is the SwitchBoard and works just as you are describing. If you let it build you one you can see how it uses tables and modifies the Captions on each button.

  5. #5
    jecanne is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    4
    Oh, and we can't use switchboards Sorry, forgot to mention that! I know, it's stupid. I might be able to figure it out, I'm looking at something from a programmer's reference right now about looping through recordsets with DAO...I'll let you know if I find anything.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Here's a link about DAO Recordsets that you may find helpful. http://www.baldyweb.com/BuildSQL.htm

  7. #7
    jecanne is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    4
    Thanks for the link, it was helpful. I think I figured this out now...I guess my question really was "How do I Extract Data from a record in a DAO Recordset?"
    http://msdn.microsoft.com/en-us/libr...ffice.12).aspx

    I just tested it on one button caption, and it works. Now I just have to loop through and write some quick macros to open the form/reports. Thanks for the help!

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You're welcome. Have fun. You can use the Thread Tools at the top of the thread to mark this thread as Solved.

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

Similar Threads

  1. Dynamic Form, Dynamic labels/ captions?
    By JFo in forum Programming
    Replies: 15
    Last Post: 10-12-2011, 08:33 PM
  2. Form with Label captions that size dynamically
    By karmacable in forum Forms
    Replies: 3
    Last Post: 09-26-2011, 10:09 PM
  3. Command button to input data in a table
    By wilsgaard in forum Forms
    Replies: 1
    Last Post: 08-07-2011, 07:59 PM
  4. Replies: 3
    Last Post: 07-29-2011, 09:30 AM
  5. Button to open on specific Data
    By glasgowlad1999 in forum Access
    Replies: 6
    Last Post: 05-15-2011, 03:46 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