Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I have a template where some text boxes are only enabled depending on what option has been chosen at a preceding combo-box. I also require, however, that if any of the text boxes on the form have not been populated, the user is prompted that the question must be answered (ie the text box must be populated).

    Code:
    Private Sub cmbmattertype_Change()
    
        If cmbmattertype = "single-matter" Then
            txtmatterno.Enabled = True
            txtmatterno.BackColor = &H80000005
            txtmatterdesc.Enabled = True
            txtmatterdesc.BackColor = &H80000005
            txtjointgroup.Enabled = False
            txtjointgroup.BackColor = &H80000000
        Else
            cmbmattertype = "multi-matter"
            txtjointgroup.Enabled = True
            txtjointgroup.BackColor = &H80000005
            txtmatterno.Enabled = False
            txtmatterno.BackColor = &H80000000
            txtmatterdesc.Enabled = False
            txtmatterdesc.BackColor = &H80000000
        End If
        
    End Sub
    
    Private Sub cmdcont_click()
        
        Selection.GoTo what:=wdGoToBookmark, Name:="requester"
        Selection.TypeText Text:=txtrequester
        
        Selection.GoTo what:=wdGoToBookmark, Name:="matter_type"
        Selection.TypeText Text:=cmbmattertype
        
        Selection.GoTo what:=wdGoToBookmark, Name:="matter_no"
        Selection.TypeText Text:=txtmatterno
        
        Selection.GoTo what:=wdGoToBookmark, Name:="client_name"
        Selection.TypeText Text:=txtclientname
        
        Selection.GoTo what:=wdGoToBookmark, Name:="matter_desc"
        Selection.TypeText Text:=txtmatterdesc
        
        Selection.GoTo what:=wdGoToBookmark, Name:="joint_group"
        Selection.TypeText Text:=txtjointgroup
        
        Selection.GoTo what:=wdGoToBookmark, Name:="name_addr"
        Selection.TypeText Text:=txtnameadd
        
        Selection.GoTo what:=wdGoToBookmark, Name:="narrative"
        Selection.TypeText Text:=txtnarrative
        
        If txtrequester = "" Then
            frmBilling1.Hide
            MsgBox "You must enter the name of the person requesting the bill."
            frmBilling1.Show
        End If
        
        If cmbmattertype = "" Then
            frmBilling1.Hide
            MsgBox "You must specify whether this is a single or multi-matter bill."
            frmBilling1.Show
        End If
        
        If txtclientname = "" Then
            frmBilling1.Hide
            MsgBox "You must enter the Client name."
            frmBilling1.Show
        End If
        
        If txtmatterno = "" Then
            frmBilling1.Hide
            MsgBox "You must enter the matter number."
            frmBilling1.Showexcep
        End If
        
        If txtmatterdesc = "" Then
            frmBilling1.Hide
            MsgBox "You must enter the matter description."
            frmBilling1.Show
        End If
        
        If txtjointgroup = "" Then
            frmBilling1.Hide
            MsgBox "You must enter the joint group number."
            frmBilling1.Show
        End If
        
        frmBilling1.Hide
        frmBilling2.Show
    
    End Sub
    
    Private Sub UserForm_Initialize()
        Me.cmbmattertype.AddItem "single-matter"
        Me.cmbmattertype.AddItem "multi-matter"
    End Sub
    I am having trouble figuring out the vb for "If txtjointgroup.Enabled = False" then don't prompt the user to populate the text box. I hope that makes sense.

    Thanks,

    Violet

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    Code:
    If txtjointgroup = "" and txtjointgroup.enabled Then
    should do it.

    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ah I was almost there then...I had something similar but not quite the same. Great, thanks Rory!

Posting Permissions

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