Consulting

Results 1 to 20 of 56

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Sep 2012
    Posts
    14
    Location
    Okay, I have simplified the form a bit. 4 pages instead of 14.

    To answer your questions:
    Main criteria to figure out (and maybe you already know these answers, but it's not apparent to me in perusing the form)

    1. What are all of your limiters (i.e., if a 1 hour curriculum, can't have more than 1 60 minute course... if you haven't selected building, don't show building chapters list)
    2. Where do you want the information saved (both in-progress, which is possible, and after the end-user has completed the form).
    3. How does the end-user modify the data entry?
    4. How are you planning on deploying this to these people... and by extension, how do you plan to upgrade when you have an issue which needs to be corrected?
    1. The only real limiters are just that- if they have not selected building it should not show. It is set now that they are able to go back and change the values which in turn enables or disables the check boxes for the buildng list. A 1 hour ciriculum however can have each of the courses in it, building,fire,electrical, mechanical and plumbing.
    2. We would like the information to save while in progress and at the end (last module save button) save the document as CourseTitleSponsorNumberDate, and tell the user the title and where it was saved.
    3. This one is a little tricky for me as, I thought the only method of entry was the user form. We would like the user to be able to open the saved document and edit the data at their will.
    4. The deployment will be through internet download. Updates will be posted to the internet.
    okay in this simplified one, Ithink some of the 'cluter' comes from my lack of vba knowledge , I have added in functions for some of the code that was repeated in the buttons.

    [vba]'Makes the module pages visible
    Private Function ModVisible()
    Dim x As Integer
    Dim y As Integer
    x = MultiPage1.Pages(0).txtChours.Value
    For y = 0 To x + 1
    Me.MultiPage1.Pages(y).Visible = True
    Next y
    End Function
    'Rsets the module pages if the course hours change
    Private Function ModReset()
    Dim x As Integer
    Dim y As Integer
    x = MultiPage1.Pages(0).txtChours.Value
    For y = (((x + 2) - 2) + 2) To 3
    Me.MultiPage1.Pages(y).Visible = False
    Next y
    End Function[/vba]

    I have also solved the problem i had earlier
    Or,is there a way to automatically do this when the user changes the credit hours to zero?
    The red text fixed that:
    [vba]'Disables the check boxes if 0 building credits are selected:
    If Me.txtBldC = 0 Then
    y = 0
    Me.CKB1.Enabled = False
    Me.CKB2.Enabled = False
    ' Checks to see if anything is selected in the Building chapter list box for Module 1:
    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 If
    End If
    ' Checks to see if anything is selected in the Building chapter list box for Module 2:
    If CKB2.Locked = True Then
    x = 0
    If y = x Then
    MultiPage1.Value = 3
    j = 0
    For i = 0 To LBB2.ListCount - 1
    If LBB2.Selected(i) Then j = j + 1
    Next i
    If MsgBox("You have " & j & " chapters selected in Module 2 under the Building Code." _
    & " Click 'OK' to clear the selected chapters.", vbOKCancel) = vbOK Then
    For i = 0 To LBB2.ListCount - 1
    LBB2.Selected(i) = False
    Next i
    CKB2.Value = False
    CKB2.Enabled = False
    CKB2.Locked = False
    Else:
    CKB2.Locked = False
    CKB2.Enabled = True
    Building2.Visible = True
    Me.txtBldC = 0
    End If
    End If
    End If
    End If[/vba]

    I think some of the problem is that I(beleive that I) need so many variables. I would love to write some functions that could take away from some of the code. I tried all day to get this working, thinking this small one would lead me to the larger ones:
    [vba]Private Function NextVisible()
    'Makes the next button invisible if the next page in the set is not visible.
    Dim MyArray(1 To 3) As String
    MyArray(1) = Me.cmdNextBtnMod1
    MyArray(2) = Me.cmdNextBtnMod2
    MyArray(3) = Me.cmdNextBtnMod3
    Dim y As Variant
    Dim x As Integer
    Dim z As Variant
    For x = 2 To 4
    For y = LBound(MyArray) To UBound(MyArray)
    z = "Me.cmdNextBtnMod" & y
    If Me.MultiPage1.Pages(x).Visible = False Then
    MsgBox z
    z.Visible = False
    ElseIf Me.MultiPage1.Pages(x).Visible = True Then
    MsgBox z
    z.Visible = True
    End If
    Next y
    Next x
    'original, this works in the code trying to get rid of these lines
    'If Me.MultiPage1.Pages(3).Visible = False Then
    ' Me.cmdNextBtnMod1.Visible = False
    'Else: Me.cmdNextBtnMod1.Visible = True
    End If
    End Function[/vba]
    I am begining to think that you can not make a variable and use it as an object. It would always fail here: z.Visible = False , told me that I need an object but the msgbox read what it needed to say?/shrug

    I have a habit of taking really big bites, but I didnt think the code was that complex just a lot of var's and pages. Which is why I started looking into the replacing an object with a variable in a loop.

    It's the weekend, the Glenlivet Nardurra, will clear my head and back at it Monday morning.
    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
  •