+ Reply to Thread
Results 1 to 19 of 19

Button to use multiple buttons

  1. #1
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Button to use multiple buttons

    Currently in my database, I have 4 buttons that update a table with some if then else and select case statements in each button. Well can I combine those to push one button and it will do all 4 buttons?
    Last edited by ncurran217; 02-17-2012 at 01:28 PM. Reason: Solved

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Button to use multiple buttons

    Depends on the code. Post the code or attach the workbook
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Button to use multiple buttons

    This is one of the buttons (all four are the same except the select case statments and if then else statements):


    Please Login or Register  to view this content.
    Last edited by ncurran217; 02-15-2012 at 03:00 PM.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Button to use multiple buttons

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  5. #5
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Button to use multiple buttons

    Ok I actually tried looking to do that but must have read over it, so I posted my code because you asked for it.

  6. #6
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Button to use multiple buttons

    Well I tried to combine code, but does it seem to be wanting to do the second part of it with the [mycategory2]

    Please Login or Register  to view this content.
    Let me know if this helps on what I am trying to do.

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: Button to use multiple buttons

    but does it seem to be wanting to do the second part of it with the [mycategory2]
    What does this mean? Working or not working?

    In looking at your code you have not defined category1 nor category2. You have category defined as a string so if it is not working that may be part of the issue.

    Alan
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  8. #8
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Button to use multiple buttons

    The second group of If Then Else statements that has this in it:

    Please Login or Register  to view this content.

    This is where I thought I would be defining it on which column to edit.
    Please Login or Register  to view this content.
    Last edited by ncurran217; 02-15-2012 at 05:18 PM.

  9. #9
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: Button to use multiple buttons

    Your Dim statements defines your strings, variants, etc.

  10. #10
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Button to use multiple buttons

    So this:

    Dim mycategory As String

    would turn into

    Dim mycategory1 As String
    Dim mycategory2 As String

    ??

  11. #11
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: Button to use multiple buttons

    Yes. Otherwise, Access doesn't know what they are and how to handle them.

  12. #12
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Button to use multiple buttons

    Ok I did that, which is what I figured, but then when I click the button the debug comes up with this highlighted in the screenshot below:

    screenshot.jpg

  13. #13
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: Button to use multiple buttons

    Any message? Have you tried stepping through the code (use the F8) key.

    Look at this video. He will show you how to step through the code to see what is causing the error.

    http://www.datapigtechnologies.com/f...vbadoloop.html

    Alan

  14. #14
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Button to use multiple buttons

    Well it wont let me step into the file. But when I go into debug mode after it comes up with the error I can hover over the Highlighted part and it shows it as NULL. Well I believe that is because it is a different column I need to edit. So how do I have a loop finish with the first column then loop through the file for the second column?

  15. #15
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: Button to use multiple buttons

    You know that individually each loop works. Take the first loop and complete it. Now at the end of the first loop insert the second loop and complete it. I can't see why this would not work for you. Alternatively, you could put each loop in a module and call them sequentially in the same code for the button. This is untested on my behalf but seems to make sense.

  16. #16
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Button to use multiple buttons

    This is what I put, but seems to only do the first loop as the second loop edits the second column and nothing ends up in the second column. Unless I have the loops coded wrong, but it seems to do the first one but skips the second one!

    Sorry new to coding and access, as you probably have seen, because you have helped me on various other things and really appreciate the help a lot!

    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Button to use multiple buttons

    Well I think I have figured it out. I changed this:

    Please Login or Register  to view this content.
    To this:
    Please Login or Register  to view this content.
    I added the myset.MoveFirst after the Loop so when it finished it would move back to the first record and then start the second loop.

  18. #18
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: Button to use multiple buttons

    Excellent. Thanks for the feedback. I haven't done much with loops so this was a bit of learning experience for me also when adding the second loop.

    Alan

  19. #19
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Button to use multiple buttons

    im glad we worked it out and able to both learn something at the same time. Ill be adding two more to it so I will let you know how it goes!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1