Custom Cardholder Scripting


Overview

Custom Cardholder scripting can be applied to programmatically control the UserText fields. Beginning in Access It! Universal.NET v5.2, control has been added for the Last Name, First Name, and Middle Initial fields.

Aside from the information below, assistance in writing custom cardholder scripting is not a service offered by RS2 Technical Support.

Applying Custom Scripting

  1. Log into Access It! Universal.NET
  2. Navigate to the Configuration menu
  3. Select User Groups
  4. Edit the first available User Group
  5. Select the Permissions tab
  6. Select Cardholder Fields
    Do not expand.
  7. Within the right hand pane select Edit Cardholder Form Behavior...

Object properties
If a property is called for a control that is not supported, an exception message is raised.

SetFocus()

  • Supported object types
    • Text Box
    • Drop List
    • Date Combo Box

Visible()

  • Supported object types
    • Text Box
    • Drop List
    • Date Combo Box

Enabled()

  • Supported object types
    • Text Box
    • Drop List
    • Date Combo Box

Text()

  • Supported object types
    • Text Box

Value()

  • Supported object types
    • Drop List
    • Date Combo Box

Backcolor()
Color value must be passed as HTML hex value ex. #000000

  • Supported object types
    • Text Box

Forecolor()
Color value must be passed as HTML hex value ex. #000000

  • Supported object types
    • Text Box

Clear()

  • Supported object types
    • Drop List

RemoveAll()

  • Supported object types
    • Drop List

AddItem()

  • Supported object types
    • Drop List

Field Permissions

If the logged in user does not have access to a usertext field, the control is not added to the form's collection. If any scripting is performed on a missing field, runtime errors will occur.  To prevent errors, use the ContainsControl function or script the code to continue on error should scripting be performed on a missing field.

ContainsControl("UserTextX")

  • Function will return True if UserText passed as a variable exists in the forms collection.

Examples
On Form update, set UserText1 to Employee when UserText2 is equal to No. This code will continue should a runtime error occur.

Public Sub Change(ObjectName)

On Error Resume Next

Select Case ObjectName

Case Form.UserControls("UserText2")

If Form.UserControls("UserText2").Text = "No" Then

Form.UserControls("UserText1").Text = "Employee"

End If

End Select

End Sub

On Form unload, ensure UserText11 is required and unique. The script will ensure the logged in user has access to UserText11  prior to ensuring it is unique.

Public Sub Unload()

If ContainsControl("UserText11") Then

If Form.UserControls("UserText11").Text = "" Then

Err.Raise 5, ,"Employee ID is required!"

End If

Dim sSql

Dim rsDuplicate

sSql = "SELECT CardholderID, UserText11 FROM Cardholders WHERE UserText11 = '" & Form.UserControls("UserText11").Text & "'"

Select Case Form.EditMode

Case 1 ' EditInProgress

sSql = sSql & " AND CardholderID <> '" & Form.CardholderID & "'"

Case 2 ' Add

End Select

Set rsDuplicate = GetRecordset(CStr(sSql))

If rsDuplicate.RecordCount > 0 Then

Err.Raise 5, ,"That Employee ID is already on file!"

End If

End If

End Sub


  • 545
  • 09-Oct-2017
  • 1754 Views