Consulting

Page 3 of 3 FirstFirst 1 2 3
Results 41 to 56 of 56

Thread: Message Box and Verify selection in a multiselect listbox issues.

  1. #41
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location
    Jason,
    I all seems sound and I think if I look around, I'll probably find som old projects where I have done something very similiar.

    My problem is that I am unorganized and often do the same thing a half a dozen ways :-(.

    What do you think about:

    cmdCancel.Value = True
    instead of
    cmdCancel_Click

    I've seen it done both ways.
    Last edited by gmaxey; 10-02-2012 at 12:52 PM.
    Greg

    Visit my website: http://gregmaxey.com

  2. #42
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    Half a dozen ways of doing the same thing isn't a bad thing... then we all get to learn something. "Fresh eyes" is what I call it.

    I didn't know that setting the .Value of a command button is the same as clicking it (which I tested, and it seems to be).

    I guess the only "problem" with cmdCancel.Value = True is that it won't cause a Compile error if the command button exists on the form, but you've forgotten to actually add the Click event. Obviously compile errors are "better" than run-time errors, generally speaking. But in this case, it would be pretty obvious at some point during development that you were missing something so essential to the form as cmdCancel_Click.

  3. #43
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    I mis-spoke. I did not mean disable really, I meant act like a Cancel button. In that clicking the X causes a controlled exit (rather than an abrupt I'm outta here regardless of whatever havoc it may cause).

    Which is not always the case for any Windows X.

  4. #44
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    Ahh... then you and I agree.

    My response, then, was directed towards scenarios where I have seen the Red X be commandeered so that it either is disabled (clicking it effectively does nothing, from the end-user's perspective) or that clicking it generates a msgbox to the effect of "You must click the Cancel button to close this form" -- both of which I've always thought were less graceful than simply redirecting the functionality to the actual cancel button.

  5. #45
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location
    The former I don't mind. The latter annoys the living daylights out of me. I also don't mind and often simply make it go away. In fact the example posted at the moment does just that but I think I'm going to change that and do it like wev'e been discussing here. That really is probably best.
    Greg

    Visit my website: http://gregmaxey.com

  6. #46
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location
    Jason/Gerry

    It should come as no surprise, but when I see something that interests me as this topic has, I will usually publish something about it:

    http://gregmaxey.mvps.org/word_tip_p...tem_lists.html

    Hardest part was crafting a title. Still don't know if I am happy with what I've chosen.

    The piece on the class object with private propeties is probably a little weak. Truth is, I don't know that much about them.

    Thanks for all of your inputs here and DAustin I didn't mean to take over your thread. Hope you don't see it that way.
    Greg

    Visit my website: http://gregmaxey.com

  7. #47
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    Greg: the page looks fantastic... and it is a great summary of all the various things described in this thread.

    Daustin: If you're getting stuck on your own project, I would highly recommend taking a look at Greg's link. The final demo of two userforms is exactly what I've been recommending (so of course, I think it's brilliant *grin*)

  8. #48
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Hmmmmm. I have to agree that "Repeating Item List" is weak, or rather, not fully descriptive. I do not know what to replace it with, but I do have to say your samples of what you mean by "repeating item list" is good.

    Multiple Similar Items?

    I agree that. for most, the use of the word "class" scares the crap of them.

    Hmmmm.

    Good article though. I will keep a copy of the link handy, as it is a great (ahem) user friendly introduction.

  9. #49
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    So you are going to UNhide the close X?

  10. #50
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location
    Gerry,

    I did in the the final demonastration code. However, in the practical example code project both forms have the "X" button hidden as Jason must have overlooked ;-).

    I did this on purpose so people looking at the demo pack documents can see both techniques.

    Thanks for you input. In Word 2013, MS calls the new content controls "Repeating Section" and they basically add a new row to a table with controls that match the controls in the previous row. The purpose of course is provide data fields so a user can repeat and create the next list item, section, row, or whatever one wants to call it.

    I give up on a better name for now as the eye beginning to cast its gaze in my direction.

    Thanks.
    Greg

    Visit my website: http://gregmaxey.com

  11. #51
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    I didn't actually download and check the code from your page, but it's nice to see that I'm wrong about not being able to hide the Red X in Word VBA user forms. I don't want to get too used to being right all the time, hehe.

    Still, that sure is a lot of work to hide that button (private declares, a subroutine which gets passed a dialog object, and then calling that subroutine in any initialize event of a form you don't want to have the Red X in). But, I'm definitely going to keep that code around if I ever need it, so thank you! That seems like it could be a (short) tip page in and of itself...

    How to Hide the Red X in Custom UserForms

  12. #52
    VBAX Regular
    Joined
    Sep 2012
    Posts
    14
    Location
    Okay, glad I could spark a conversation in which everyone learns something.

    I learned something important. Do not show any one a prototype project until you are sure you want to go that direction.

    So with that said and after 10 people (4 of which have nothing to do with this at all, but feel that they are ever so important) have given input. We finally have a form with that 95% of the parties involved (not sure why they are involved) can agree to. Oh and I am the 5%, because I liked the two form one with no pages.
    So the stipulations were:
    "We liked the pages, what happened to the pages. Give us the pages!"
    "It must and I mean must fit on a 800 x 600 resolution. Some of our users do not know how to change that setting!"
    "This one is too tall and to cluttered, I liked the first one."

    So attached is what was agreed upon. Now I have had a frustrating two days so not too much has been done.

    I like the idea of removing the red X, question regarding that. I have put that code in for the frmMod, it works if you just run that form but does not work if the from is called by the information form. I am lost on that one.

    The forms now have the function of the previous iteration. I am stuck on crossing the forms with variables.
    This code would tell the user if something in the listbox was selected:
    [VBA] If CKB1.Locked = True Then
    x = 0
    If y = x Then
    MultiPage1.Value = 2
    j = 0
    For i = 0 To LBB1.ListCount - 1
    If LBB1.Selected(i) Then j = j + 1
    Next i
    If MsgBox("You have " & j & " chapters selected in Module 1 under the Building Code." _
    & " Click 'OK' to clear the selected chapters.", vbOKCancel) = vbOK Then
    For i = 0 To LBB1.ListCount - 1
    LBB1.Selected(i) = False
    Next i
    CKB1.Value = False
    CKB1.Enabled = False
    Else:
    CKB1.Locked = False
    CKB1.Enabled = True
    Building1.Visible = True
    Me.txtBldC = 0
    End If
    End[/VBA]

    I tried something along the lines of
    [VBA] If frmMod.CKBuilding.Locked = True Then
    j = 0
    For i = 0 To LBB1.ListCount - 1
    If frmMod.LBBuilding.Selected(i) Then j = j + 1
    Next i
    If MsgBox("You have " & j & " chapters selected in Module 1 under the Building Code." _
    & " Click 'OK' to clear the selected chapters.", vbOKCancel) = vbOK Then
    For i = 0 To frmMod.LBBuilding.ListCount - 1
    frmMod.LBBuilding.Selected(i) = False
    Next i
    frmMod.CKBuilding.Value = False
    frmMod.CKBuilding.Enabled = False
    Else:
    frmMod.CKBuilding.Locked = False
    frmMod.CKBuilding.Enabled = True
    frmMod.BuildingFrame.Visible = True
    Me.txtBuildingHours = 0
    End If
    End[/VBA]

    but it would lock up, before I even entered a number for building hours.

    I will look at Greg’s stuff tomorrow. I glanced at it today, it is only one form but follows the same input pattern that I am going for now.

    A nudge in the right direction for verifying things across forms would be great.
    Attached Files Attached Files

  13. #53
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    Haven't had a chance to look at any of this code (nor will I, at least for today), but I just wanted to make sure you know that the actual design of the form is totally immaterial to the construction and organization of your data.

    Please don't go back to the "pages" implementation you had before... you can easily give a "pages" look without having to implement it the way you did.

    The only thing this design spec forces is that you can't store a bunch of individual sub-forms into a collection -- you'll need to use either a UDT/Array combo or a Class/Collection combo.

    I would look over Greg's page before you start copying/pasting a bunch of controls.

  14. #54
    VBAX Regular
    Joined
    Sep 2012
    Posts
    14
    Location
    I understand that now, another afternoon wasted just trying to get the exact same thing that I had before.

    I did separate the pages out into user forms. I was looking at the verification that Greg used in his forms, tried implementing that into mine with good success other than the boxes connected to the spin buttons, when you open that form the ok button is enabled, and locks when you enter the box I thought I set to unlock it.

    Will work some more on it tomorrow.

    If either of you gets a chance to look at these two trials any comments/ criticism you have would be appreciated.
    Attached Files Attached Files

  15. #55
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location
    daustin,

    The "ok" button is enabled because you never evaluated it in the Initialize event to disabled it. In the function you wrote to validate it, there is no mention of the state of the spinbuttons or the text fields they affect.
    Greg

    Visit my website: http://gregmaxey.com

  16. #56
    VBAX Regular
    Joined
    Sep 2012
    Posts
    14
    Location
    Okay took a break. Back at it this afternoon, thanks for the spot gmaxey, fixed the enable issue there. I took most of the verification stuff out of the code for the moment since I run this constantly to see how it works.
    Finally got the forms talking to each other, just not the way I intended.
    Two major things:
    ·The course info form is the main data entry. I have it set to remove items from the list if the user lowers the number of credit hours after adding CE modules. Which it does it just leaves the last items which I thought I had it remove by stepping backwards in the for loop.
    ·The addmodule form shows the list of all the CE modules added by the user. There is a delete button on this form, it does delete the module then rename the rest of the modules. however the program then fails when the user tries to edit a module.
    I believe that both of these issues have something to do with the way the collection items are named. [/font]
    Again just a nudge in the right direction would be appreciated.

    I did look at the class stuff, and maybe I haven't grasped it fully yet but I think this is the best option (for my skill level) at the moment.
    Attached Files Attached Files

Posting Permissions

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