Creating a simple script to restrict specific GL accounts from certain users

Hi, I am trying to create a script that puts the focus back on the GL account field when specific GL accounts are selected by user. So, when a user enters a GL account with a UDF_RESTRICTED value of Y, then Sage will focus back on the GL account and not allow the user to enter the specified account. Here is my script. I've tried several options and none has worked so far.

If oSession.CompanyCode = "CMH" Then
if oSession.UserCode = "TIM" Then

Restricted = ""

'********************GET STATUS*****************************
RetVal = oBusObj.GetValue("UDF_RESTRICTED$",Restricted)


if Restricted = "Y" then
retMsg = oSession.AsObject(oSession.UI).MessageBox("Restricted " & Restricted)

retVal = oscript.SetError("Restricted Account")

End If

End If
End if 'Company check