+ Reply to Thread
Results 1 to 14 of 14

Booleans and Userform_initialize()

  1. #1
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Booleans and Userform_initialize()

    Ok this is driving me insane. What am I doing wrong?

    In a module I have this:

    Please Login or Register  to view this content.
    Then in a userform called 'Admin1' I have this:

    Please Login or Register  to view this content.
    Then for each button on a UF called 'Admin' I have this (called Delete_click and Edit_click):

    Please Login or Register  to view this content.

    The idea is that whatever button is clicked (either Add, Edit or Delete) then a MsgBox appears with that message.

    But it doesn't work?! Any ideas?

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Booleans and Userform_initialize()

    Is admin1 the name of the form? If so you are setting the variable after the form is shown.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Booleans and Userform_initialize()

    Hi Nathan,

    Ahh yes that works, although only once? What I mean is that on the second form I have a button which takes the user back to the 'Admin' form (in case they wish to Add or Edit, etc).

    Is there a reason why it only works once?

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Booleans and Userform_initialize()

    AddIsChecked is set to True after you show Admin1.

    The Initialize event of Admin1 is triggered when you show Admin1.

    AddIsChecked will only get set to True after Admin1 has been closed.
    If posting code please use code tags, see here.

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,972

    Re: Booleans and Userform_initialize()

    What's the code to load the admin form?

    The code in the admin form should be more like:
    Please Login or Register  to view this content.
    and the code in the admin1 form should have something like:
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  6. #6
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Booleans and Userform_initialize()

    Thanks guys. Think I understand.

    I put this behind the Add button:

    Please Login or Register  to view this content.
    But I get an argument not optional on the Unload.Me?

    @Rory - where do I put your admin1 code? Which sub?

  7. #7
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Booleans and Userform_initialize()

    Should have said - all forms are ShowModal = False.

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,972

    Re: Booleans and Userform_initialize()

    It's
    Please Login or Register  to view this content.
    , not
    Please Login or Register  to view this content.
    and you do not re-show the admin1 form - it should take care of that. Whichever button(s) on the admin1 form loads admin should use the code I suggested.

    It would be much easier if you post either the workbook, or all the code.

  9. #9
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Booleans and Userform_initialize()

    Hi romper,

    Sorry I really am not getting this. 'Unload Me' just closes the form but doesn't show anything.

    I have uploaded my project with irrelevant stuff stripped out. Can you help?
    Attached Files Attached Files

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Booleans and Userform_initialize()

    Perhaps.
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Booleans and Userform_initialize()

    Hi Norie,

    Thanks. I have this in 'Admin'

    Please Login or Register  to view this content.
    This in 'Admin 1' when the 'Back to Admin' button is clicked:

    Please Login or Register  to view this content.
    And this is also in Admin1 so that when it initializes I receive a MsgBox (so that I know it works). At the moment it only works once. Clicking the Back to Home button seems to be destroying something.


    Please Login or Register  to view this content.

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,972

    Re: Booleans and Userform_initialize()

    Sorry - I had your flow back to front. In admin you should have:
    Please Login or Register  to view this content.
    and in admin1:
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Booleans and Userform_initialize()

    Hi Romper,

    You have just saved my keyboard!! Thanks a bunch (and to everyone else!)

    Thank you. : )

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,972

    Re: Booleans and Userform_initialize()

    Glad to help.

+ 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. Userform_initialize event
    By rajeev.raj in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-23-2012, 03:07 AM
  2. Replies: 4
    Last Post: 06-06-2010, 11:42 AM
  3. [SOLVED] UserForm_Initialize
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-13-2006, 11:52 AM
  4. [SOLVED] LOOKUP with Booleans
    By landen99@gmail.com in forum Excel General
    Replies: 3
    Last Post: 09-15-2005, 03:05 AM

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