Sage MAS 90 and 200 Sage MAS 500 blogs Product Feedback Support Training
Reply
Regular Visitor
cmorton
Posts: 9
Registered: 11-18-2008
0

CheckBox Click event being fired on Form Activate/Edit events

Hello All,

      We have a checkbox bound to a custom table for Enter Sales Orders and Quotes. The checkBox has a script that is associated with the Click event and is working as expected. Unfortunately when we access a previously entered sales order that previously had the checkbox checked the script is being fired again even though the CheckBox has not been clicked again. Seems to be firing on the Form Activate/Edit event.

 

Has anyone seen this before or know of a way to prevent the CheckBox Click event from firing on the Form Activate/Edit event?

 

Here is a really simple example for a checkbox1 on a form that is bound to a custom table, and is causing the Click event to be fired when form is reloaded with a previously checked record.



Sub CheckBox1_Click
If Form.Controls("CheckBox1").value = 0 Then
MsgBox("CheckBox is not checked")
Else
MsgBox("CheckBox is checked")
End If
End Sub

 

Cheers in advance for any ideas or solutions.

 

Thanks ~ Chad

Sage MAS 500 Customer
trodman
Posts: 234
Registered: 02-13-2009
0

Re: CheckBox Click event being fired on Form Activate/Edit events

Chad,

 

That's strange.  I haven't used that event before, but wouldn't expect it to behave that way.  Is there another even that you can use to get around this odd behavior?

Tim Rodman
Programmer Analyst
rodmant@robbinstbm.com
Version 7.30.6.0 (March 2011)
Sage MAS Partner
jmiles
Posts: 34
Registered: 12-04-2008
0

Re: CheckBox Click event being fired on Form Activate/Edit events

It looks like that event should have been named "Change" instead of "Click". The click event seems to fire anytime the checkbox is changed, whether the change originated from the control being clicked or from code changing it programmatically. Since the checkbox doesn't know about MAS 500's UI model, it'll still execute when a change in its value comes from the form opening or from the record changing.

 

What are you looking to accomplish with the script on the checkbox's change event? I agree that you might be able to use another event to accomplish the same thing. The checkbox has a "LostFocus" event, and that is more likely to capture direct user interaction with the checkbox. You'd just need to check whether the value has changed before you execute your code. You might be able to use Session.AppDatabase.Lookup to lookup the saved value of the checkbox, or you could make use of the checkbox's "Tag" property to track changes. Alternatively, you could put your code in the Form_Save event if the code can wait until the record is saved.

Jason Miles
Technology Consultant
SGS Technology Group
http://www.sgstech.com