View Single Post
  #4  
Old May 28th, 2010, 08:40 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default Toggle button vs Command button

The simplest would be by way of an option group. Just use option buttons
rather than radio buttons or command buttons. You would use one Integer
field where you are now using a separate field for each button (I expect),
but if the choices are mutually exclusive only one field is needed.

In a form where the buttons were not contiguous I used some code. In the
form's module:

Public Sub ButtonsUp()

Dim ctl As Control

For Each ctl In Me.Controls
If ctl.ControlType = acToggleButton Then
Controls(ctl.Name).Value = 0
End If
Next ctl

End Sub

In the Click event of Toggle1:

Call ButtonsUp

Me.Toggle1 = 1

In Toggle2 set Toggle2 to 1, and so forth.

The ButtonsUp procedure sets all toggle buttons to 0 (not pressed), then sets
one button to 1 (pressed).


Steve Stad wrote:
Thanks Tom,

This (your) code works fine for the toggle buttons. i.e., I removed the
.setfocus line.
Private Sub Toggle23_Click()
HelpWindow.Value = "CTR Rule - toggle button"
End Sub
....
Is there a way for a toggle button shading to change from pressed to
Unpressed when another toggle button is pressed. Right now each toggle
button is highlighted as pressed unless you press it again.

This may be related to trying to set the focus at an inopportune time.
Fortunately it is not necessary, if you replace your two lines with:

[quoted text clipped - 17 lines]
End Sub

.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201005/1