Results 1 to 7 of 7

Thread: Toggle button

  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I want to have a toggle button that enters yes ot no values in the table and changes the caption of the button.
    The button should be names contact but when pressing the value yes hsould be entered and the caption should be chnaged to customer.I have a function but something is worng with it and does not funcion properly.
    Van you help me?
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Why would you use a toggle button here? It's easier for the user to click the check box.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='800260' date='28-Oct-2009 10:12']Why would you use a toggle button here? It's easier for the user to click the check box.[/quote]

    Thank you for the reply.
    Because i want to change the caption on the same button.When the check box is No, the caption should read Contacts when the check box is Yes, the caption should read Customer.Also i want to make visible the label when the caption is Yes.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Try this:

    Code:
    Private Sub CmdACustomer_Click()
      With Me.CmdACustomer
    	If .Value = True Then
    	  .Caption = "customer"
    	  .ForeColor = vbBlack
    	  Me!LblACustomer.Visible = True
    	Else
    	  .Caption = "contact"
    	  .ForeColor = vbBlue
    	  Me!LblACustomer.Visible = False
    	End If
      End With
    End Sub

  5. #5
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='800262' date='28-Oct-2009 10:23']Try this:

    Code:
    Private Sub CmdACustomer_Click()
      With Me.CmdACustomer
    	If .Value = True Then
    	  .Caption = "customer"
    	  .ForeColor = vbBlack
    	  Me!LblACustomer.Visible = True
    	Else
    	  .Caption = "contact"
    	  .ForeColor = vbBlue
    	  Me!LblACustomer.Visible = False
    	End If
      End With
    End Sub
    [/quote]

    Thank you very much for your reply.The code works , and when the value is True, that is to say when i click on it,the field is in the table is turned to Yes and the label is changed to "Customer". My problem is that when i choose another client, say number 3 the caption stays with the old name "customer" even though the value is False. Also when i choose again a customer with value Yes, the caption remains unchanged.So my problem is with the caption when i go through the clients
    Attached Files Attached Files

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You need to execute the same code in the On Current event of the form. This event occurs when the user moves to another record. The easiest way to do this is to call Command2_Click:

    Code:
    Private Sub Form_Current()
      Call Command2_Click
    End Sub

  7. #7
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='800279' date='28-Oct-2009 12:30']You need to execute the same code in the On Current event of the form. This event occurs when the user moves to another record. The easiest way to do this is to call Command2_Click:

    Code:
    Private Sub Form_Current()
      Call Command2_Click
    End Sub
    [/quote]


    Thank you very much ! problem solved!

Posting Permissions

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