+ Reply to Thread
Results 1 to 5 of 5

VBA Excel Form with 'modes'

  1. #1
    Registered User
    Join Date
    04-22-2018
    Location
    M憖ico
    MS-Off Ver
    2016
    Posts
    3

    VBA Excel Form with 'modes'

    Hello!

    I have an Excel vba form with:

    • a set of textboxes and comboboxes
    • a set of buttons

    The values entered in one subset from the textboxes and comboboxes (two of them) should define a 'mode' for the form. Depending of the values of that subset:

    • some textboxes and comboboxes need to be enabled or disabled (maybe even hide)
    • some buttons need to be enabled or disabled (maybe even hide)
    • the tab sequence for textboxes, comboboxes and buttons may be redefined
    • a certain textbox, combobox or buton should get the focus.

    I already understand I can't do those actions within the code for the AfterUpdate event... but then, how can I implement that?

    Thanks a lot!

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: VBA Excel Form with 'modes'

    Your description is very general. You will probably need to check the Change event on the textboxes and comboboxes that define the mode. But to get a specific answer you will need to provide the specifics.

    Can you attach a file with your form? Which textboxes and comboboxes define a "mode"? What values define what mode?

    The paper clip icon does not work for attachments. Instead, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    04-22-2018
    Location
    M憖ico
    MS-Off Ver
    2016
    Posts
    3

    Re: VBA Excel Form with 'modes'

    Hello 6StringJazzer! Do you play guitar? I do! =)

    I attached a jpg with an image of the form I want to create.

    I want to have 'Form State 1', where only objects 1, 2 and 11 are enabled, and object 1 has the focus.

    Once user has entered info on fields 1 and 2, I query a database (fields 1 and 2 form a primary key on a table there). If I get a record, then I go to 'Form State 2' if I don't, then I go to 'Form State 3'.

    In 'Form State 2', I populate objects 3, 4, 5, 6, 7 from the results of the SQL Query, and then only objects 3, 4, 5, 6, 7, 8, 9, 10 and 11 are enabled, and object 10 gets the focus.

    In 'Form State 3', only objects 3, 4, 5, 6, 7, 8, 10 and 11 are enabled, and object 3 gets the focus.

    Button 8 does an INSERT or UPDATE over the SQL table, clears all objects, and sends the Form to 'Form State 1'

    Button 9 does a DELETE over the SQL table, clears all objects, and sends the Form to 'Form State 1'

    Button 10 clears all objects, and sends the Form to 'Form State 1'

    Button 11 clears all objects, sends the Form to 'Form State 1', and exits the User Form.


    How can I get this? I was thinking it was going to be possible using code within the AfterUpdate event, but, surprise! it doesn't works that way. =(
    Attached Images Attached Images

  4. #4
    Registered User
    Join Date
    04-22-2018
    Location
    M憖ico
    MS-Off Ver
    2016
    Posts
    3

    Re: VBA Excel Form with 'modes'

    Jeff,

    ... and while I wait for your advice (or someone else's), I'll try to use the Change events as you proposed...

    Thanks! =)

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: VBA Excel Form with 'modes'

    I would have 3 subs to transition to each of your states. Here is the example for how to get to State1. You would repeat similar logic for State2 and State3 based on your description

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to program my macro to choose between multiple modes and no modes
    By joeywalsh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-27-2017, 04:51 PM
  2. debug modes learning
    By grkchakri in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-18-2013, 04:51 AM
  3. Excel 2010: Mode.Sngl not returning lowest of multiple modes
    By yukontornado in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-17-2013, 04:26 PM
  4. Excel 2007 : Excel 2007 Save Modes
    By ravichander in forum Excel General
    Replies: 4
    Last Post: 07-11-2008, 01:21 PM
  5. [SOLVED] switching between modes
    By Joe in forum Excel General
    Replies: 3
    Last Post: 02-09-2006, 10:00 AM
  6. switching between modes
    By Joe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-08-2006, 12:00 PM
  7. Design/run modes for a button
    By Mike Reedich in forum Excel General
    Replies: 1
    Last Post: 04-02-2005, 11:06 AM

Tags for this Thread

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