Skip to content
Mandla edited this page Sep 25, 2017 · 4 revisions

In order to successfully edit the application, a number of changes must be made to ensure that the various components coordinate as expected. The majority of changes are contained within the ConstParams module, but in some cases changes in other section of the application may be required. This section outlines the two most likely situations in which changes will be made - adding and removing elements from forms.

Adding Fields

Changing Form Appearance

The first stage of adding a field involves modifying the appearance of the form. Using the drag and drop editor, fields should be added in such a way that the visual layout of the form remains consistent and cohesive.

  • Only text inputs and combo boxes should be used.

  • Field dimensions should line up to the other elements on the form.

  • Consistent spacing should be used.

  • The same colour scheme should be used maintained.

  • Mandatory fields should be indicated with an asterisk (*).

Note: In some cases, it may be necessary to drastically alter the appearance of the form in order to accomodate needed changes. In this event, large numbers of fields should be organised into similarly sized groups using frames.

Field Settings

The drag and drop view has a window that allows field parameters to be changed to alter appearance and function. This section specifies which parameters need to be set to particular values in order to maintain consistent behaviour across fields and forms.

For all fields:

Parameter Value
BackColor &H80000005& - Window Background
BorderColor &H80000006& - Window Frame
ForeColor &H80000008& - Window Text
BorderStyle 1 - fmBorderStyleSingle

For large text input fields:

Parameter Value
EnterKeyBehaviour True
ScrollBars True
MultiLine True

For time fields:

Parameter Value
MaxLength 4

Naming Convention

For the application to function correctly, fields must be named following a specific format. Every field should be named InputN, where N is the position of that field on the form. So the first field should be Input1, the second Input2, and so on. Every field should have a descriptive label, named LabelN following the same pattern, such that Label3 is the label for Input3.

Updating Form Code

Although most of the application functionality is implemented elsewhere, some changes may need to be made to the code within each actual form object. This code is accessible by double-clicking on a particular form template from the drag and drop view. The form code is separated in Sub subroutines, and in the following circumstances, these must be added and edited directly. Subroutines do not need to be arranged in any particular order, but it is highly recommended to organise them in a grouped and logical order.

Populating Combo Boxes

If the field being added is a combo box, then code needs to be added to create the options that consist of the fields valid input values. Every form has a userForm_Initialize() function, and for a combo box named Input4, the following two lines need to be added to this subroutine in order to populate it when a user clicks on it.

Me.Input4.AddItem "Yes"
Me.Input4.AddItem "No"

These lines must come before the final line of the function:

initialiseForm [form constant name], Me
Linking Options with Children

If the new field is a combo box that has children, another subroutine must be implemented so that changes to the combo box de/activates its children in real time. If the same Input4 from the above example is an option field with the form constant FO_OPT_CTCHECKED, then the following subroutine would be used:

Private Sub Input4_Change()
    If UCase(Me.Input1.Value) = "YES" Then
        SetActiveChildFields FO_OPT_CTCHECKED, True
    ElseIf UCase(Me.Input1.Value) = "NO" Then
        SetActiveChildFields FO_OPT_CTCHECKED, False
    End If
End Sub
Textbox Right Click

For large text boxes, in order enable copy and paste by right clicking the mouse, the following subrouting needs to be added to the form code. For text input `Input2':

Private Sub Input2_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If Button = vbKeyRButton Then Call ShowTextMenu(Me.Controls("Input2"))
End Sub
Number-Only Text Input

In some cases, it is desirable to only allow numeric input into a text box. WHere this is the case, the following subroutine must be added to the form code. For text input Input2:

Private Sub Input2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    isInt KeyAscii
End Sub

Updating Existing Elements

Cascading Name Values

Once all new fields (and their accompanying labels) have been added, all fields and labels on the form that come after a newly added field must have their names adjusted such that their number matches their new position. So if a form with 10 fields has a new field added at the third position, previous inputs and labels 3 - 10 must then be incremented by one.

Updating TabIndex

Along with updating the names of fields, the TabIndex must also be adjusted. This is the parameter that determines in which order fields are traversed when the user presses the tab key to jump from field to field. This must be updated when fields are added to ensure users can continue to navigate the form efficiently.

Updating Constant Parameters

The second stage of adding fields to forms involves updating the ConstParams module. This involves 5 steps, although some of these might be unnecessary depending on the type of input:

  1. Add the field to the list of form constants

    If the field is an option field, add it to both 'INPUT' and 'OPT' constant sections. Otherwise, just the 'INPUT' section. Use the appropriate prefixes: [form abbreviation]_[constant section]_[field name]. Enumerate the constant appropriately. The number assigned to the constant should match the number in that field's name. Update the following field constants for that form accordingly, so that no numbers are duplicated and all constants match their field's number.

  2. Update the form's General Parameters

    NUM_OPTS and NUM_FIELDS should be incremented as appropriate NUM_COMMAS should be changed if additional line breaks will be needed. FULL_RANGE and CELL RANGE should be updated in order to fit the new size of the form's section in the fields sheet. X_OFFSET and Y_OFFSET should not be changed.

  3. Add new field to relevent Parameter Arrays

    For an example field, FO_INP_NEWFIELD:

Condition Array Update
FO_INP_NEWFIELD is a required field requiredInputs(FO_INP_NEWFIELD) = 1
FO_INP_NEWFIELD needs spellchecking spellCheckedInputs(FO_INP_NEWFIELD) = 1
FO_INP_NEWFIELD is a time field timeTextInputs(FO_INP_NEWFIELD) = 1
FO_INP_NEWFIELD ends the line of output lineBreakList(4) = FO_INP_NEWFIELD
FO_INP_NEWFIELD is an option field optionInputs(FO_INP_NEWFIELD) = FO_OPT_NEWFIELD
FO_INP_NEWFIELD is child of FO_INP_PARENT optionFields(FO_OPT_PARENT, FO_INP_NEWFIELD) = CHILD_NRM

Note: Pay attention to when the _OPT_ and _INP_ prefixes are used, as using the wrong prefix will lead to incorrect functionality.

Updating Excel Sheet

The final stage of adding elements to a particular form is to change the fields excel sheet. This sheet is hidden by default, and should be hidden again once changes have been made to it. This sheet defines the titles that get paired to the text from the form in the output that gets sent to the user's clipboard. When a new field is added to a form, that form's title list should be found, and the new field's title should be added in the appropriate location.

Removing Fields

Removing fields involves most of the same processes as field addition, but reversed:

  • Ensure remaining fields are re-positioned to maintain visual cohesion.

  • Decrement remaining field and label names to ensure no missing gaps exist.

  • Decrement form constants in ConstParams module.

  • Update form's General Parameters to reflect new structure.

  • Remove references to removed field(s) in Parameter Arrays.

  • Remove field title(s) from field Sheet, and update range accordingly.