textbox selections


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: textbox selections

  1. #1
    jitterbug Guest

    textbox selections


    Hi ____________,
    I am trying to limit the user to only us one of two related text boxes. here
    is my code so far, if you type in one text box it will not allow you to type
    in the other, however i would also like it to, if the user delectes his/her
    selection for it to resume and allow both options

    Private Sub txtAcre_Change()
    If frmUse.txtAcre.Enabled = True Then
    frmUse.txtFeet.Enabled = False
    End If

    If frmUse.txtAcre.Value = False Then
    frmUse.txtFeet.Enabled = True
    End If
    End Sub

    Private Sub UserForm_Click()
    If frmUse.txtFeet.Enabled = True Then
    frmUse.txtAcre.Enabled = False
    End If

    If frmUse.txtFeet.Value = False Then
    frmUse.txtAcre.Enabled = True
    End If
    End Sub

    I also have another question, I have coded check boxes to query a db. however
    when one check box is choosen it selects all the data and not just the data
    related to the "checked" chkbox. here the code is long, as i have 7 check
    boxes for options.

    any suggestions on either...

    thanks
    brett


  2. #2
    Rick Rothstein Guest

    Re: textbox selections

    What about this simpler method...

    Private Sub txtFeet_GotFocus()
    If Len(txtAcre.Text) Then txtAcre.SetFocus
    End Sub

    Private Sub txtAcre_GotFocus()
    If Len(txtFeet.Text) Then txtFeet.SetFocus
    End Sub


    Rick



    "jitterbug" <cholewa@uwm.edu> wrote in message news:3cc85e80@10.1.10.29...
    >
    > Hi ____________,
    > I am trying to limit the user to only us one of two related text boxes. here
    > is my code so far, if you type in one text box it will not allow you to type
    > in the other, however i would also like it to, if the user delectes his/her
    > selection for it to resume and allow both options
    >
    > Private Sub txtAcre_Change()
    > If frmUse.txtAcre.Enabled = True Then
    > frmUse.txtFeet.Enabled = False
    > End If
    >
    > If frmUse.txtAcre.Value = False Then
    > frmUse.txtFeet.Enabled = True
    > End If
    > End Sub
    >
    > Private Sub UserForm_Click()
    > If frmUse.txtFeet.Enabled = True Then
    > frmUse.txtAcre.Enabled = False
    > End If
    >
    > If frmUse.txtFeet.Value = False Then
    > frmUse.txtAcre.Enabled = True
    > End If
    > End Sub
    >
    > I also have another question, I have coded check boxes to query a db. however
    > when one check box is choosen it selects all the data and not just the data
    > related to the "checked" chkbox. here the code is long, as i have 7 check
    > boxes for options.
    >
    > any suggestions on either...
    >
    > thanks
    > brett
    >



  3. #3
    dnagel Guest

    Re: textbox selections

    thats a little disconcerting... I think Disabling it might be better
    so that the user can visually see that he can't use it is better...

    Private Sub SetEnabled (TrueFalse as boolean)
    frmUse.txtAcre.Enabled = TrueFalse
    frmUse.txtFeet.Enabled = (Not TrueFalse)
    End Sub



    For more TB's you could build an Enum and use a control array
    if textboxes...

    (Air code...)

    Option Explicit

    Private Enum enmTBNames
    Acre = 0
    Feet
    Inches
    Yards
    End Enum

    Private Sub SetEnabled(txtBoxes As Variant, WhichTB As enmTBNames)

    Dim i%
    For i = txtBoxes.LBound To txtBoxes.UBound
    txtBoxes(i).Enabled = False
    Next i

    txtBoxes(WhichTB).Enabled = True

    End Sub

    'This will move to the next TB every time the change event is fired...
    ' needs a trap for Index > 3...

    Private Sub Text1_Change(Index As Integer)
    SetEnabled Text1(), Index + 1
    End Sub


    D.


    "Rick Rothstein" <rickNOSPAMnews@NOSPAMcomcast.net> wrote in message news:3cc8a7aa$1@10.1.10.29...
    | What about this simpler method...
    |
    | Private Sub txtFeet_GotFocus()
    | If Len(txtAcre.Text) Then txtAcre.SetFocus
    | End Sub
    |
    | Private Sub txtAcre_GotFocus()
    | If Len(txtFeet.Text) Then txtFeet.SetFocus
    | End Sub
    |
    |
    | Rick
    |
    |
    |
    | "jitterbug" <cholewa@uwm.edu> wrote in message news:3cc85e80@10.1.10.29...
    | >
    | > Hi ____________,
    | > I am trying to limit the user to only us one of two related text boxes. here
    | > is my code so far, if you type in one text box it will not allow you to type
    | > in the other, however i would also like it to, if the user delectes his/her
    | > selection for it to resume and allow both options
    | >
    | > Private Sub txtAcre_Change()
    | > If frmUse.txtAcre.Enabled = True Then
    | > frmUse.txtFeet.Enabled = False
    | > End If
    | >
    | > If frmUse.txtAcre.Value = False Then
    | > frmUse.txtFeet.Enabled = True
    | > End If
    | > End Sub
    | >
    | > Private Sub UserForm_Click()
    | > If frmUse.txtFeet.Enabled = True Then
    | > frmUse.txtAcre.Enabled = False
    | > End If
    | >
    | > If frmUse.txtFeet.Value = False Then
    | > frmUse.txtAcre.Enabled = True
    | > End If
    | > End Sub
    | >
    | > I also have another question, I have coded check boxes to query a db. however
    | > when one check box is choosen it selects all the data and not just the data
    | > related to the "checked" chkbox. here the code is long, as i have 7 check
    | > boxes for options.
    | >
    | > any suggestions on either...
    | >
    | > thanks
    | > brett
    | >
    |



  4. #4
    Veign Guest

    Re: textbox selections

    What about using one TextBox with two option buttons below that dictate
    whether the data in side is in units of Feet of Acres..

    --
    Veign
    www.veign.com
    Code Samples & Sample Projects
    http://www.veign.com/information/app.../info_app.html
    Submit Your Best Code (you keep the rights)
    http://www.veign.com/information/app...de_submit.html
    ---------
    "dnagel" <GrandNagel@hotmail.com> wrote in message
    news:3cc9636e$1@10.1.10.29...
    > thats a little disconcerting... I think Disabling it might be better
    > so that the user can visually see that he can't use it is better...
    >
    > Private Sub SetEnabled (TrueFalse as boolean)
    > frmUse.txtAcre.Enabled = TrueFalse
    > frmUse.txtFeet.Enabled = (Not TrueFalse)
    > End Sub
    >
    >
    >
    > For more TB's you could build an Enum and use a control array
    > if textboxes...
    >
    > (Air code...)
    >
    > Option Explicit
    >
    > Private Enum enmTBNames
    > Acre = 0
    > Feet
    > Inches
    > Yards
    > End Enum
    >
    > Private Sub SetEnabled(txtBoxes As Variant, WhichTB As enmTBNames)
    >
    > Dim i%
    > For i = txtBoxes.LBound To txtBoxes.UBound
    > txtBoxes(i).Enabled = False
    > Next i
    >
    > txtBoxes(WhichTB).Enabled = True
    >
    > End Sub
    >
    > 'This will move to the next TB every time the change event is fired...
    > ' needs a trap for Index > 3...
    >
    > Private Sub Text1_Change(Index As Integer)
    > SetEnabled Text1(), Index + 1
    > End Sub
    >
    >
    > D.
    >
    >
    > "Rick Rothstein" <rickNOSPAMnews@NOSPAMcomcast.net> wrote in message

    news:3cc8a7aa$1@10.1.10.29...
    > | What about this simpler method...
    > |
    > | Private Sub txtFeet_GotFocus()
    > | If Len(txtAcre.Text) Then txtAcre.SetFocus
    > | End Sub
    > |
    > | Private Sub txtAcre_GotFocus()
    > | If Len(txtFeet.Text) Then txtFeet.SetFocus
    > | End Sub
    > |
    > |
    > | Rick
    > |
    > |
    > |
    > | "jitterbug" <cholewa@uwm.edu> wrote in message

    news:3cc85e80@10.1.10.29...
    > | >
    > | > Hi ____________,
    > | > I am trying to limit the user to only us one of two related text

    boxes. here
    > | > is my code so far, if you type in one text box it will not allow you

    to type
    > | > in the other, however i would also like it to, if the user delectes

    his/her
    > | > selection for it to resume and allow both options
    > | >
    > | > Private Sub txtAcre_Change()
    > | > If frmUse.txtAcre.Enabled = True Then
    > | > frmUse.txtFeet.Enabled = False
    > | > End If
    > | >
    > | > If frmUse.txtAcre.Value = False Then
    > | > frmUse.txtFeet.Enabled = True
    > | > End If
    > | > End Sub
    > | >
    > | > Private Sub UserForm_Click()
    > | > If frmUse.txtFeet.Enabled = True Then
    > | > frmUse.txtAcre.Enabled = False
    > | > End If
    > | >
    > | > If frmUse.txtFeet.Value = False Then
    > | > frmUse.txtAcre.Enabled = True
    > | > End If
    > | > End Sub
    > | >
    > | > I also have another question, I have coded check boxes to query a db.

    however
    > | > when one check box is choosen it selects all the data and not just the

    data
    > | > related to the "checked" chkbox. here the code is long, as i have 7

    check
    > | > boxes for options.
    > | >
    > | > any suggestions on either...
    > | >
    > | > thanks
    > | > brett
    > | >
    > |
    >
    >




  5. #5
    Rick Rothstein Guest

    Re: textbox selections

    > thats a little disconcerting... I think Disabling it might be better
    > so that the user can visually see that he can't use it is better...


    Maybe its me, but doesn't a disabled TextBox with no text in it look just like an enabled
    TextBox with no text in it?

    Rick


  6. #6
    Dean Earley Guest

    Re: textbox selections

    "Rick Rothstein" <rickNOSPAMnews@NOSPAMcomcast.net> wrote in message news:3cc97872@10.1.10.29...
    > > thats a little disconcerting... I think Disabling it might be better
    > > so that the user can visually see that he can't use it is better...

    >
    > Maybe its me, but doesn't a disabled TextBox with no text in it look just like an enabled
    > TextBox with no text in it?


    It does on VB6 on Win2K.

    If I compile on Win2k, it is white when disabled on both 98 and 2K
    When I compile on 98, it is gray when disabled on 98 only (I think)

    Never simple is it )

    --
    Dean Earley (dean.earley@icode.co.uk)
    Assistant Developer

    iCode Systems



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center