Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

3 phase toggle button

Status
Not open for further replies.

NeilT123

Technical User
Jan 6, 2005
302
GB
I have a field NRateChecked and I would like a button on a continuous form which is based on this field but has a default caption/value of "unchecked" and when clicked goes to "checked" and if clicked again goes to "N/A" and when clicked again back to "unchecked" saving the relevant value in the field.

Not really sure how to do this, or if it can be done so can anyone give me some guidance please.

Thank you
 
Set its TripleState property to True and put something like this in its click method:
Code:
Private Sub togTest_Click()
    Select Case togTest.Value
        Case -1
            togTest.Caption = "On"
        Case 0
            togTest.Caption = "Off"
        Case Else
            togTest.Caption = "N/A"
        End Select
End Sub

Geoff Franklin
 
How are ya NeilT123 . . .
NeilT123 said:
[blue] ... I would like a button on a continuous form which is based on this field ...[/blue]
In parallel with [blue]dhookom[/blue] set the following properties of the field:

Special Effect [blue]Raised[/blue]
Default Value [blue]"UnChecked"[/blue]

Then in the controls [blue]On Mouse Down[/blue] event, copy/paste the following:
Code:
[blue]   If Me.NRateChecked = "UnChecked" Then
      Me.NRateChecked = "Checked"
   ElseIf Me.NRateChecked = "Checked" Then
      Me.NRateChecked = "N/A"
   Else
      Me.NRateChecked = "UnChecked"
   End If[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thank you for the suggestions. I decided I needed 4 options so that meant I couldn't use the "triple" option on the command button.
I did a bit more searching and I think I have created what I want as follows:
At the bottom a blank inactive command button so it looks like a button.
Over the top a transparent textbox with the control source NRateStatus so as to show the name.
On top a transparent command button, no caption and the following code in the on click

Code:
Private Sub CmdNRateStatus_Click()
'the first line deals with records with no value then the rest is a loop
If IsNull(NRateStatus) Then
    Me.NRateStatus = "TBC"
ElseIf Me.NRateStatus = "TBC" Then
    Me.NRateStatus = "CONF"
ElseIf Me.NRateStatus = "CONF" Then
    Me.NRateStatus = "N/A"
ElseIf Me.NRateStatus = "N/A" Then
    Me.NRateStatus = " "
ElseIf Me.NRateStatus = " " Then
    Me.NRateStatus = "TBC"
End If

End Sub

It seems to work but have I made this unnecessarily complicated?
 
NeilT123 . . .

When you say:
NeilT123 said:
[blue][purple]At the bottom[/purple] a blank inactive command button so it looks like a button.[/blue]
Are you talking the bottom of the [blue]detail area[/blue] or the [blue]form footer?[/blue]

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
NeilT123 . . .

Just curious ...

Doesn't [blue]" "[/blue] mean the same as [blue]"N/A"?[/blue]

If I were doing this it would be:
Code:
[blue]   If Trim(Me.NRateStatus & "") = "" Then
       Me.NRateStatus = "TBC"
   ElseIf Me.NRateStatus = "TBC" Then
       Me.NRateStatus = "CONF"
   ElseIf Me.NRateStatus = "CONF" Then
       Me.NRateStatus = "N/A"
   Else
       Me.NRateStatus = "TBC"
   End If[/blue]
This leaves something meaningful for each record instead of [blue]" "[/blue].

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Hi AceMan1

In answer to your questions:

At the bottom probably means at the back. I have created a 3 layer "button" with the blank inactive command button at the back(bottom) and then a transparent text box in front of that and a transparent command button in front of that. The "button" is in the detail section of a continuous form.

The reason for the " " is that my database is 6 years old and a change in legislation means that I now need to prove and record the fact that I have considered N rates. So I have created a field NRateStatus and for all new records from this year the NRateStatus will be CONF(confirmed), TBC or N/A however the new legislation does not affect all of the old records.

I often need to produce reports based on historic information so I didn't want to update all of the records to N/A or TBC as this would show if I ran a historic report but because my "new toggle" button is based on an IF it didn't recognise an empty field hence why I put the 1st line of code
Code:
If IsNull(NRateStatus) Then
Me.NRateStatus = "TBC"
I hope this makes sense.

Would it be better/cleaner to use your code or does it not really make any difference?
Code:
 If Trim(Me.NRateStatus & "") = "" Then
       Me.NRateStatus = "TBC"
Thank you for your help with this.

Neil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top