A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Toggle button vs Command button



 
 
Thread Tools Display Modes
  #1  
Old May 28th, 2010, 03:14 PM posted to microsoft.public.access.forms
Steve Stad
external usenet poster
 
Posts: 89
Default Toggle button vs Command button

I was using command buttons to write text in a text box. The command buttons
work fine. I was thinking of using toggle buttons because toggle buttons
change color/shading when pressed. The toggle button writes the text in the
box but I get a 'Run-time error '2115' - The macro or function set to the
BeforeUpdate or ValidationRule property for this field is preventing dbname
from saving data in the field. END/DEBUG. I am using the 'OnClick' Event
to write the text. Do I need code in another event?

Private Sub Toggle21_Click()
HelpWindow.SetFocus
HelpWindow.Text = "Writes this text"
End Sub
  #2  
Old May 28th, 2010, 03:20 PM posted to microsoft.public.access.forms
Tom van Stiphout[_2_]
external usenet poster
 
Posts: 1,653
Default Toggle button vs Command button

On Fri, 28 May 2010 07:14:01 -0700, Steve Stad
wrote:

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:
HelpWindow.Value = "Hello World"
(.Text requires the control to have focus; .Value does not)

-Tom.
Microsoft Access MVP


I was using command buttons to write text in a text box. The command buttons
work fine. I was thinking of using toggle buttons because toggle buttons
change color/shading when pressed. The toggle button writes the text in the
box but I get a 'Run-time error '2115' - The macro or function set to the
BeforeUpdate or ValidationRule property for this field is preventing dbname
from saving data in the field. END/DEBUG. I am using the 'OnClick' Event
to write the text. Do I need code in another event?

Private Sub Toggle21_Click()
HelpWindow.SetFocus
HelpWindow.Text = "Writes this text"
End Sub

  #3  
Old May 28th, 2010, 05:00 PM posted to microsoft.public.access.forms
Steve Stad
external usenet poster
 
Posts: 89
Default Toggle button vs Command button

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.

"Tom van Stiphout" wrote:

On Fri, 28 May 2010 07:14:01 -0700, Steve Stad
wrote:

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:
HelpWindow.Value = "Hello World"
(.Text requires the control to have focus; .Value does not)

-Tom.
Microsoft Access MVP


I was using command buttons to write text in a text box. The command buttons
work fine. I was thinking of using toggle buttons because toggle buttons
change color/shading when pressed. The toggle button writes the text in the
box but I get a 'Run-time error '2115' - The macro or function set to the
BeforeUpdate or ValidationRule property for this field is preventing dbname
from saving data in the field. END/DEBUG. I am using the 'OnClick' Event
to write the text. Do I need code in another event?

Private Sub Toggle21_Click()
HelpWindow.SetFocus
HelpWindow.Text = "Writes this text"
End Sub

.

  #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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:16 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.