Results 1 to 11 of 11

Thread: [RESOLVED] saving changes to a form at runtime

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2007
    Posts
    3

    Resolved [RESOLVED] saving changes to a form at runtime

    I want to create an application (it is actually a vba addin application) where I have a form with 2 option buttons (option button 1 is set to true by default) and at run time lets say the user selects option button 2. How can i capture this change so that next time the form is opened it will still reflect the change ie. show that option button 2 is selected.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: saving changes to a form at runtime

    Thread moved to Office Development forum

  3. #3
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: saving changes to a form at runtime

    I'm not sure you can if option1 is set true by default. You could save the value and on form Load check that value and set it appropriately.
    Exactly the best way to do this would depend on the specifics of your app. For example, do you want it to be set to the last saved value overall, or the last saved value for each user? You may have other considerations as well.
    Tengo mas preguntas que contestas

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: saving changes to a form at runtime

    you would have to save that info somewhere, the main choices are inside the excel workbook, to the registry, use savesetting, very easy, or a text or ini file, any of those choices could accommadate multiple users if required
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: saving changes to a form at runtime

    If the registry is not locked down, that would be my choice.

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2007
    Posts
    3

    Re: saving changes to a form at runtime

    ok thanks - thats good idea - will try saving the values somewhere and see how that goes -will let you know if it works

    Thanks again guys

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: saving changes to a form at runtime

    It will work. It takes a bit of coding and testing, but not all that much.

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: saving changes to a form at runtime

    I would opt for saving it to a file as registry access may be denied or restricted.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: saving changes to a form at runtime

    If this is Access, you could also save it to a table. Or if records have a date/time stamp, get the value from the most recent record.
    Tengo mas preguntas que contestas

  10. #10

    Thread Starter
    New Member
    Join Date
    Nov 2007
    Posts
    3

    Re: saving changes to a form at runtime

    well ive tried a couple of the above suggestions and i have found 2 different methods that work.

    the saveSetting and GetSetting methods for saving and accessing data from the registry works
    and i have simply managed save the variables to a worksheet in my addin workbork and used the 'thisworkbook.save' method to update the changes in my addin worksheet every time the user changes the option button on the form.

    I suppose its now just a matter of deciding which is the most appropriate one, which may be the 2nd one for the reasons mentioned above regarding registry access. either way i think my problem seems to be sorted out.

    thanks alot guys - that was very helpful indeed.

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: saving changes to a form at runtime

    Welcome to the forums.

    If you consider this resolved, you could help us out by pulling down the Thread Tools menu and clicking the Mark Thread Resolved menu item. That will let everyone know that you have your answer.

    Thank you.

Posting Permissions

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



Click Here to Expand Forum to Full Width