From: Steve Stad on 28 May 2010 10:14 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
From: Tom van Stiphout on 28 May 2010 10:20 On Fri, 28 May 2010 07:14:01 -0700, Steve Stad <SteveStad(a)discussions.microsoft.com> 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
From: Steve Stad on 28 May 2010 12:00 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 > <SteveStad(a)discussions.microsoft.com> 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 > . >
From: BruceM via AccessMonster.com on 28 May 2010 15:40 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/Forums.aspx/access-forms/201005/1
|
Pages: 1 Prev: Check boxes to run queries Next: Matching data in two tables |