checkbox values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lee123
    Contributor
    • Feb 2007
    • 556

    checkbox values

    i have on a form customers information and i have added a checkbox to the form to make visible these textboxes if additional information is needed for the customer.

    question:

    how do i make it if a customer needs the checkbox clicked the textboxes will show for only that customer and not all. you see i have an adodc control on the form that gets the information for the other textboxes with access (2000) for the backend. i have put buttons on the form to scroll through the records without using the adodc (which i have made invisible on the form) so when scroll through the records only the ones that have the checkbox checked should show and not all the records i hope i have made sense

    I'm using Visual basic 6.0

    thanks,
    lee123
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by lee123
    i have on a form customers information and i have added a checkbox to the form to make visible these textboxes if additional information is needed for the customer.

    question:

    how do i make it if a customer needs the checkbox clicked the textboxes will show for only that customer and not all. you see i have an adodc control on the form that gets the information for the other textboxes with access (2000) for the backend. i have put buttons on the form to scroll through the records without using the adodc (which i have made invisible on the form) so when scroll through the records only the ones that have the checkbox checked should show and not all the records i hope i have made sense

    I'm using Visual basic 6.0

    thanks,
    lee123
    Hello, lee123!

    Just passing through making sure your post is not uinanswered, time zones that whole deal...

    Unfortunately, I have a piece of code that queries using the like operator, but the idea is you'd need to add that customer's name to the textbox on the VB form then hit submit, the recordset, ADODC1 recordset, would get filled with only that customer's data, which you can page through.

    I am still learning VB, I am not sure how to mastermind this into checkboxes. You let me, I 'll tell you what to do, guide you through.

    Anything you have working by the way can be added for a closer by our experts here, may help shed some light:-)

    In a bit!

    Comment

    • Dököll
      Recognized Expert Top Contributor
      • Nov 2006
      • 2379

      #3
      Originally posted by Dököll
      Hello, lee123!

      Just passing through making sure your post is not uinanswered, time zones that whole deal...

      Unfortunately, I have a piece of code that queries using the like operator, but the idea is you'd need to add that customer's name to the textbox on the VB form then hit submit, the recordset, ADODC1 recordset, would get filled with only that customer's data, which you can page through.

      I am still learning VB, I am not sure how to mastermind this into checkboxes. You let me, I 'll tell you what to do, guide you through.

      Anything you have working by the way can be added for a closer by our experts here, may help shed some light:-)

      In a bit!
      I was thinking lee123, perhaps your checkboxes can act as your submit button, get it. If we add the code under the checkbox and not the submit button, you would in fact be querying for that customer.

      I may be way off:-)

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        If I'm reading the question correctly, you just want the textboxes to appear or disappear automatically as you scroll through the records, based on the value of a field (which is displayed as a checkbox).

        You should be able to do so by coding in the appropriate event procedure on the data control. Not sure exactly which event, though. I seem to recall there are ones which are fired when you move between records, before/after the record is displayed, and so on. I may be getting mixed up with forms in MS Access, though. I do know the built-in data control has a Reposition event.

        Another alternative might be to just watch for a change in the value of the checkbox - either by using an event procedure of the control, or a timer.

        Comment

        • lee123
          Contributor
          • Feb 2007
          • 556

          #5
          Hey killer42 & Dokoll:

          thanks for getting back with me you two. but killer42 you have hit the nail on the head (sorta speak) i have put a code in the form_load because in access i think you have to do this and put the code in the checkbox also. but i tried in my form (vb) but when i scrolled through the records the checkbox was checked on all and not just the ones i have checked but i'll try this what you have stated. i'll get back with you and tell you if it worked or not.

          thanks,
          lee123

          Comment

          • lee123
            Contributor
            • Feb 2007
            • 556

            #6
            oh just so you have an idea what i have in the checkbox here it is:

            Code:
             If Check2.Value Then
                    txtVehicle2.Visible = True
                    txtVehicle3.Visible = True
                    Label21.Visible = True
                    Label22.Visible = True
                    Label17.Visible = True
                    txtHowManyVeh.Visible = True
            Else           
                    txtVehicle2.Visible = False
                    txtVehicle3.Visible = False
                    txtHowManyVeh.Visible = False
                    Label21.Visible = False
                    Label22.Visible = False
                    Label17.Visible = False
                End If
            Thanks,
            lee123

            Comment

            • lotus18
              Contributor
              • Nov 2007
              • 865

              #7
              Originally posted by lee123
              oh just so you have an idea what i have in the checkbox here it is:

              Code:
               If Check2.Value Then
                      txtVehicle2.Visible = True
                      txtVehicle3.Visible = True
                      Label21.Visible = True
                      Label22.Visible = True
                      Label17.Visible = True
                      txtHowManyVeh.Visible = True
              Else           
                      txtVehicle2.Visible = False
                      txtVehicle3.Visible = False
                      txtHowManyVeh.Visible = False
                      Label21.Visible = False
                      Label22.Visible = False
                      Label17.Visible = False
                  End If
              Thanks,
              lee123
              Hey You had forgotten to add value to a checkbox. Minimizing the codes:

              [CODE=vb]Public Sub CheckValue(a As Boolean)
              txtVehicle2.Vis ible = a
              txtVehicle3.Vis ible = a
              txtHowManyVeh.V isible = a
              Label21.Visible = a
              Label22.Visible = a
              Label17.Visible = a
              End Sub

              If Check2.Value=1 Then
              CheckValue True
              Else
              CheckValue False
              End If
              [/CODE]

              Rey Sean

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                Oh, so we want to minimise code, do we? :) Well, I'll take that challenge.

                Without changing your CheckValue sub...[CODE=vb]CheckValue (Check2 <> 0)[/CODE]

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  lee123, anything you put in the Form_Load event procedure will only be executed once, when the form is loaded. You need to use an event which will occur at the point you are interested in . That is, when you change records.
                  Last edited by Killer42; Jan 17 '08, 02:01 AM.

                  Comment

                  • daniel aristidou
                    Contributor
                    • Aug 2007
                    • 494

                    #10
                    Originally posted by Killer42
                    lee123, anything you put in the Form_Load event procedure will only be executed once, when the form is loaded. You need to use an event which will occur at the point you are interested in . That is, when you change records.
                    Could you not use the textbox.textcha naged event on the textbox containing the primary key........ wait im not sure whether that is vb6..,,,

                    Comment

                    Working...