Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Toggle button (Access 2000)

    Toggle in place of Yes/No field?



    In my table Clients i have an Yes/No field called Turndown.Depending whether
    the field is clicked or not, i have different functions.
    However, the Yes/No field on the form is not very convenient.For example,if a client has turned down at first, and then changed his mind,it is very difficult to click again on the field and clear it.
    I think the use of a toggle button would be better.But how to tie it up with the field TurnDown? I have shown a small example in the attachment

    Can somebody send me an example of a good and effective toggle button?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Toggle button (Access 2000)

    I'm not sure what you want, but you can simply right-click the check box (in design view), and select Change To | Toggle Button in the popup menu. The Toggle button will still be bound to the TurnDown field.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toggle button (Access 2000)

    Thank you.Very simple but effective.Can i change the caption my button CmdTurnDown
    when Yes to read "TrunedDown" and when not to read "Accepted"?

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

    Re: Toggle button (Access 2000)

    Yes, you have to put some code in two places:
    - In the On Click event of the button, so that the caption changes when the user clicks it:
    - In the On Current event of the form, so that the caption changes as the user moves from record to record.

    Private Sub cmdTurnDown_Click()
    SetCaption
    End Sub

    Private Sub Form_Current()
    SetCaption
    End Sub

    Private Sub SetCaption()
    If Me.cmdTurnDown Then
    Me.cmdTurnDown.Caption = "Turned Down"
    Else
    Me.cmdTurnDown.Caption = "Accepted"
    End If
    End Sub

  5. #5
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toggle button (Access 2000)

    It works perfect.!!I I wanted to add on some colour if the client has turned down,so
    i added the line Me.CmdTurnDown.BackColor = 255 but Access didnt accept it.Why is it so ?


    Private Sub SetCaption()
    If Me.cmdTurnDown Then
    Me.cmdTurnDown.Caption = "Turned Down"
    Me.CmdTurnDown.BackColor = 255

    Else
    Me.cmdTurnDown.Caption = "Accepted"
    End If

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Toggle button (Access 2000)

    BackColor is not a property of a toggle button. Toggle buttons always use the color set for 3D objects in Windows. You can change the ForeColor (that is the color of the text), however:

    Private Sub SetCaption()
    With Me.cmdTurnDown
    If .Value = True Then
    .Caption = "Turned Down"
    .ForeColor = vbRed
    Else
    .Caption = "Accepted"
    .ForeColor = vbBlack
    End If
    End With
    End Sub

Posting Permissions

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