events do not fire (1 Viewer)

dreamdelerium

Registered User.
Local time
Today, 08:12
Joined
Aug 24, 2007
Messages
88
hi everyone. im looking for some help. when i programatically set a value for a control (ie, check a check box) why doesnt the associated event fire?

for example, if i programatically set checkboxA to checked, the checkbox will become checked but the onclick event doesnt fire. how do i get it to do this.

im creating a set of forms in access 2003
 

DCrake

Remembered
Local time
Today, 16:12
Joined
Jun 8, 2005
Messages
8,632
Is your checkbox part of an option group?

view the properites of the checkbox and scroll down to the On Click event if is states [Event Procedure] clicck on the build button and examine the code. Place a breakpoint on the first line then save the form and retry.

If there is no event on the On Click property then the procedure is located elsewhere.
David
 

dreamdelerium

Registered User.
Local time
Today, 08:12
Joined
Aug 24, 2007
Messages
88
i think i should explaine more:

as an ex, i have a form with a check box and a text box. the check box has thsi onclick event:

Code:
Private Sub CheckBox1_Click()
If Me.CheckBox1.Value = -1 Then
Me.TextBox2.Enabled = True
Else
Me.TextBox2.Enabled = False
End If
End Sub

if the user checks the check box, this work
but if i have a button with this event:

Code:
Me.Checkbox1.value= -1
i would expect the checkboxs onclick event to fire (when the button is pushed), making the textbox.enable to be set to true, which doesnt work
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 16:12
Joined
Sep 12, 2006
Messages
15,695
if you set text box oe other control values in code - no events fire (although the record will become dirty, or new)

the events only fire when you interact with them directly
 

MSAccessRookie

AWF VIP
Local time
Today, 11:12
Joined
May 2, 2008
Messages
3,428
thats what i was afraid of. so, no way arround this huh?


What about creating a common procedure/function to execute? If you set the value in the code, can't you call the same procedure/function that would be called if the event had been triggered through normal means?

Note that if the code is small enough, you can always duplicate it, but that creates the potential for one version being updated and another not being updated if the procedure/function needs to be changed at some future date.
 

missinglinq

AWF VIP
Local time
Today, 11:12
Joined
Jun 20, 2003
Messages
6,423
Whenever you do something like this, all you have to do is to call the event that would normally be triggered:

Code:
Private Sub YourButton_Click()
  Me.CheckBox1.Value = -1
  [B]Call CheckBox1_Click[/B]
End Sub
 

Users who are viewing this thread

Top Bottom