Sage MAS 90 and 200 Sage MAS 500 blogs Product Feedback Support Training
Reply
Regular Contributor
jbuddecke
Posts: 75
Registered: 05-06-2009
0

Customizer - Code works in 7.3 but not 7.2

I am trying to get the following customizer script in Maintain GL Accounts that works in 7.3 to work in 7.2, but it is not.  The message pops up, but the field is not properly enabled and the focus is not set.  An alternative would be for the entire form to be cleared after the popup message. 

 

Sub Form_New

 dim seg1val, seg2val

  msg = Form.Controls("glaGLAcct").text

  seg1val = Form.Controls("glaGLAcct").text

  seg2val = mid(Form.Controls("glaGLAcct").text,6,4)

 

Set MyDatabase = Session.AppDatabase

  

  if left(seg1val,1) < 5 and seg2val <> "0000" then 

      msgbox "GL account is invalid!  Department must be '0000'."

      Mydatabase.Cancel

        Form.Controls("glaglacct").enabled=true

Form.Controls("glaGLAcct").setfocus   '**** NOT WORKING          

  elseif seg1val >  4 and seg2val = "0000" then

      msgbox "GL account is invalid!  Deparment can't be '0000'."

      Mydatabase.Cancel

       Form.Controls("glaglacct").enabled=true

Form.Controls("glaGLAcct").setfocus   '**** NOT WORKING       

  end if

end sub

Jeb Buddecke
ISM - Director, MAS 500
jeb@goism.com
Sage MAS Partner
jmiles
Posts: 34
Registered: 12-04-2008
0

Re: Customizer - Code works in 7.3 but not 7.2

The "Mydatabase.Cancel" calls concern me. What prompted you to use that method? That's a pretty low-level operation, and I'll bet it wasn't intended for use in Customizer.

 

I assume you want to cancel the creation of the new GL account when the account number is not valid. Why not programmatically click the "Cancel" toolbar button instead of manipulating the ODBC operation:

 

Form.Controls(0).Parent.HandleToolbarClick "K7"

 

You shouldn't need to enable the lookup or set the focus if you do this. The cancel button will do that for you.

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