Microsoft Access VBA Tutorials for self-paced learning, Class Modules, SQL Techniques, and AI Integration Guides.

Limit to List Combo Box

Limit to List Combo Box.

Combo Boxes in tables and forms are used to quickly insert frequently used values into data fields. The source data for a combo box can come from a table, a query, or a value list. To use it, the User clicks the drop-down arrow to display the available options and selects the required value. Alternatively, the user can also type in values directly into the combo box control.

However, one important property setting determines how the combo box behaves:

  • The first setting restricts the user to selecting only from the existing list and prevents invalid values in the target field.

  • Limit to List = Yes

  • On Not in List = [Event Procedure]

When the Limit to List property is set to Yes, you can only select or type values that already exist in the combo box list. Any manually entered values that are not in the list will be rejected. To use a new value, it must first be added to the source table (or query/value list) that supplies data to the combo box.

Example:

Suppose you have a table containing a list of fruits and have only two items: Apple and Cherry. This list is used as the source for a combo box on a Sales Form. If the Limit to List property is set to Yes, you cannot type Orange directly into the field. Instead, you must first add Orange to the fruit table; only then will it appear as a valid option in the combo box.

The On-Not-in-List Event.

When the On Not in List Property is set to an Event Procedure, it is executed when the user enters a new value (Orange) manually into the Control-Source Field of the ComboBox. We can write code in the Event Procedure to add the new value to the ComboBox Source List (after the User approves) and update the ComboBox on the Form.

This method saves the time that would otherwise be spent opening the combo box’s source table and manually adding new items. In addition, values added directly to the source table do not refresh the combo box.

Let us try this using the above example items as Source Data.

Combo Box Row Source Table.

  1. Create a new Table with a single Field Name: Fruit and select the Data Type Text.

  2. Save the Table Structure and name it Fruitlist.

  3. Open the Table in Datasheet View and key in Apple and Cherry as two records.

  4. Close and save the Table with the records.

  5. Create another table with the following Structure:

    Table Structure
    Field Name Data Type Size
    ID AutoNumber
    Description Text 50
    Quantity Numeric Long Integer
    UnitPrice Numeric Double
  6. Before saving the Structure, click on the second Field Data Type (Text) Column to select it.

  7. Click on the Lookup Tab on the Property Sheet below.


    Combo Box Property Settings.

  8. Select the Display Control Property and select Combo Box from the drop-down control.

  9. The Row Source Type Property Value will be Table/Query; if it is not, then select it from the drop-down control.

  10. Click on the drop-down control of the Row Source Property and select the Table Fruit list from the displayed list of Tables.

  11. Change the Column Width Property and List Width Property Values to 1".

  12. Change the Limit to List Property Value to Yes.

  13. Save the Table Structure with the name Sales.

  14. Open the Table in Datasheet View and add a new record with Apple, 100, and 1.5 in Description, Quantity, and UnitPrice Fields, respectively.

  15. Close and save the Table with the record.

  16. Select the Sales Table, select Form from the Insert Menu.

  17. Create a Form using the Form Wizard in Column Format and save it named Sales.

    Testing Settings.

  18. Open the Sales Form in the normal view.

    Since we have added the Combo Box to the Table Structure, it already appears on the form.

  19. Press Ctrl++ (or click on the New Record control on the Record Navigation control) to add a new blank record on the Form.

  20. Click the drop-down control of the Combo Box, and you will find the list of fruits: Apple and Cherry there.

  21. But you key in Orange into the Description field and press Enter.

    You will be greeted with the following error message:

    If you want to enter the value Orange on the Form, you must add that item to the Fruit List source Table first.

  22. To add a new item, open the Fruit List table, enter Orange as a new record, and then close the table.

However, this action will not automatically refresh the Combobox contents to include Orange. To see the updated value, you must either close and reopen the Sales form or add a command button to the form and write code that requeries the combo box contents.

What we did manually in response to the above error message can be automated by writing a VBA SubRoutine that can be run through the On Not In List Event Procedure. You don't need to close and reopen the Form to refresh the Combo Box contents either.

Add New Item through VBA.

  1. Open the Sales Form in Design View.

  2. Click on the Description Field to select the Combo Box control.

  3. Display the Property Sheet (View -> Properties).

  4. Find and click on the On Not in List Property.

  5. Select Event Procedure from the drop-down list.

  6. Click the Build button (. . .) To open the VBA Module.

  7. Copy and paste the following Code into the Module, overwriting the top and bottom Procedure lines already appearing in the Module:

    Private Sub Description_NotInList(NewData As String, Response As Integer)
    Dim strmsg As String, rst As Recordset, db As Database
    
    If Response Then
        strmsg = "Entered Item not in List!" & vbCr & vbCr & "Add to List...?"
          If MsgBox(strmsg, vbYesNo + vbDefaultButton2 + vbQuestion, "Not in List") = vbYes Then
           Set db = CurrentDb
           Set rst = db.OpenRecordset("FruitList", dbOpenDynaset)
           rst.AddNew
           rst![Fruit] = NewData
           rst.Update
           rst.Close
           Me.Description.Undo
           Me.Description.Requery
           Me![Description] = NewData
           Me.Refresh
        End If
        Response = 0
    End If
    End Sub
  8. Save and Close the Sales Form.

    Trial Run Program.

  9. Open it in a normal view.

  10. Now, type the name of any fruit not available in the Combo Box list (say, Peach) in the Description field.

    You will be greeted with the following Message Box:

  11. Click the Command Button with the Label Yes to add the new item keyed in the Description Field to the Fruit List Table and refresh the Combo Box List.

  12. Now, click on the drop-down control of the Combo Box, and you can see that the new item is added to the list and accepted in the Description Field as well.

Share:

Input Masks and Data Entry

Input Masks and Data Entry.

Input masks are a special set of characters that can be applied to the Input Mask property of data fields in Microsoft Access to simplify data entry. They can also be used on Forms.

For example:

  • Text values can automatically convert to uppercase.

  • Slashes (/) can be inserted automatically in date formats to separate the day, month, and year.

  • Hyphens (-) can be inserted into telephone numbers to separate the country code, area code, and local number.

When entering large volumes of information manually, input masks greatly reduce effort, ensure consistency, and help maintain data in a standardized format for both entry and display.

Let us look at an example. Assume that we have a Text Field for entering Telephone Numbers, and the sample input mask Property setting is given below:

Input Mask of Telephone Number

(###) ###-#######;0;_

When the field is active before entering any values into the field, it will look like the display below:

(___) ___-____

The keystrokes you will make to type the telephone number are +914792416637, but the value will be automatically inserted in the appropriate segments, guided by the Input mask as (+91) 479-2416637. You don’t need to type the brackets, spaces, or hyphens that separate the country code, area code, and telephone number—these are inserted automatically by the input mask.

The Input Mask Property Value is expressed in three segments separated by semicolons.

The first segment value is the Input mask itself: (###) ###-#######.

The second segment value is 0 or 1. If the value is 1, the segment separator characters (brackets, spaces, and hyphens) are stored with the data in the field,  (+91) 479-2416637 (the field size must be large enough to store all the separator characters). If the value is 0, the keyed-in data alone is stored in the field as +914792416637, and the Input Mask is used for displaying the values.

The third segment value (the underscore character in the example) is used to indicate data entry positions with underscores.

When the Input mask character is # in all required character positions, it allows you to enter Digits, Spaces, plus, or Minus symbols only in the field, or leave the entire field empty.

The input mask character 9 works similarly, but it does not allow the use of plus (+) or minus (-) symbols in the data field.

The input mask character 0 restricts entry to digits 0–9 only, and, like 9, it does not permit plus or minus symbols.

Input Mask Date Field.

Input Mask Example2 (Date Field Input Mask): 99/99/0000;0;_

Sample Data Entry: _1/_1/1984 or 01/01/1984

Date value changes into 01/01/1984

In the Day and Month positions, you are allowed to enter a Space, but in the Year position, all four digits must be entered because the 0 input mask will not allow Spaces and cannot leave that area empty. But you can leave the Date Field totally empty.

Input Mask in Text Field.

Input Mask Example3 (Text Field): >CCCCCCCCCCCCCCC;0;_

Allows you to enter any Character or Space, or you can leave the data field blank. The Text Value entered will be converted to uppercase; you don't need to worry about the CAPS LOCK setting.

If you use the word Password as an Input Mask, then whatever data you enter into the field will appear as a series of * characters, and the actual value entered is not shown.

The list of Input Mask characters and their usage descriptions is given below.

Character    Description

0            Digit (0 to 9, entry required, plus [+] and minus [-] signs not allowed).

9            Digit or space (entry not required, plus and minus signs not allowed).

#            Digit or space (entry not required; spaces are displayed as blanks while in Edit mode, but blanks are removed when data is saved; plus and minus signs allowed).

L            Letter (A to Z, entry required).

?            Letter (A to Z, entry optional).

A            Letter or digit (entry required).

a            Letter or digit (entry optional).

&            Any character or a space (entry required).

C            Any character or a space (entry optional).

. , : ; - /  Decimal placeholder and thousand, date, and time separators (separator: A character that separates units of text or numbers.). (The actual character used depends on the settings in the Regional Settings Properties dialog box in Windows Control Panel).

<            Causes all characters to be converted to lowercase.

>            Causes all characters to be converted to uppercase.

!            Causes the input mask to display from right to left, rather than from left to right. Characters typed into the mask always fill it from left to right. You can include the exclamation point anywhere in the input mask.

\            Causes the character that follows to be displayed as the literal character (for example, \A is displayed as just A).

Password     Displays * in all keyed character positions.

You can use the above characters in mixed format to control or display field contents.

For example, the Input Mask>C<CCCCCCCCCCCCCC;0;_ will change the first character in uppercase and the rest of the text lowercase and accepts up to 15 characters in the field.

Technorati Tags:

Earlier Post Link References:

Share:

Menus with Option Group Control

Menus with Option Group Control.

We can create cascading menus on a form using Tab Controls and Option Group controls. Multiple menus can be arranged neatly, one behind the other, allowing the user to select the main menu option to display the corresponding submenu.

For example, the sample image below illustrates a Main Menu with three options, each representing a different category, along with submenu options for each category.

When the Data Files option is selected in the main menu, the corresponding Submenu appears on the right, allowing the user to click any option to open and work with that file.

Similarly, selecting Reports in the main menu displays the report options in the same area, replacing the previously shown data file options. Choosing the Views option brings up its respective sub-menu, again replacing the previous display.

In this way, multiple menus can be arranged and transitioned in the same space with a seamless, dynamic interface. These menus can be programmed using VBA or macros to run the detailed options associated with each selection.

Simple Interface Design and Code.

You don't need to work with any complicated VBA Programs except a few simple lines of Code and Macros. The design task is simple, and once you know the trick, you can implement it anywhere in no time.

The sample Design image of the above Form is given below:

  1. Open a new Form in the Design view.

  2. Select the Option Group Control from the Toolbox and draw it near the left side of the Form in the Detail Section.

  3. Enter the three Options (Data Files, Reports, and Views), pressing the Tab Key in each step to advance to the next line in the Wizard.

  4. Click Finish to create the Option Group Control with Radio Button Type Controls, with the Keyed-in Values as Labels.

  5. Change the Caption Value of the attached child label to Main Menu and position it above the Options Group control in the design.

  6. Click on the outer frame of the Options Group Control to select it and display its Property Sheet (View -> Properties).

  7. Change the Name Property Value to Frame0 and the Border color Property Value to 0.

  8. Select the Tab Control from the Toolbox and place it to the right of the Options Group Control (check the design image above).

    A Tab Control with two Pages will be created.  We must insert one more Page into the Tab Control.

  9. Right-click on the Tab Control to display the Shortcut Menu.

  10. Select Insert Page from the Shortcut Menu to add another Page to the Tab Control.

  11. While the Tab Control is in the selected state, display its Property Sheet.

  12. Change the Name Property Value to TabCtl9.

    NB: No dot (.) at the end of the name when you change it on the control.

    Data Tables Menu.

  13. Click on the First Page of the Tab Control to make it current.

  14. Select Option Group Control from the Toolbox and draw it on the First Page of the Tab Control.

  15. Enter the following Options (or Form Names of your own Tables in your Database) by pressing the Tab Key after each option on the Wizard:

    • Employees
    • Orders
    • Order Details
    • Customers
    • Products
  16. Click Finish to complete creation of the Option Group with Radio Button Style options.

  17. Display the Options Group Property Sheet (View ->Properties).

  18. Change the following Property Values as shown below:

    • Name = Frame1
    • Default Value = 0
    • Border Color = 0
  19. Change the Caption of the Child-Label attached to the Options Group Control to Data Files.  Change the Label width to the size of the Options Group Control. Position the Label above, as shown in the design image above.

    We must create two Option Group Controls on the 2nd and 3rd Pages of the Tab Control with a different set of Options.

    The Reports Menu.

  20. Follow Steps 13 to 19 to create an Option Group Control on the 2nd Page of the Tab Control with the following options, and name the Option Group Frame as Frame2 and the Child-Label Caption as Report List:

    • Employee Address Book
    • Employee Phone Book
    • Invoice
    • Monthly Report
    • Quarterly Report

    Create Report Names from your own Database, replacing the above List.

    Data View Menu.

  21. Create another Option Group Control on the 3rd Page of the Tab Control with the following options, or create your own Options and name the Option Group as Frame3 and Child-Label Caption as View Options:

    • View Inventory
    • View Orders
    • View Customers
    • View Suppliers

    Now, we have to write a few lines of VBA Code for the Main Menu Option Group to select the detailed Options Page of the Tab Control based on the menu selection. Even though Page Captions show something like Page10, Page11, and Page12, each Page is indexed as 0, 1, and 2. If you want to select the second Page of the Tab Control to display the Report Options, then you must address the Tab Control Page2 in Code as TabCtl9.Pages(1).Setfocus.

    We can select an individual Page of the Tab Control by clicking in the Page.  But this manual action will not synchronize with the Main Menu. The items on the Option Group Menu also have index numbers from 1 to the number of items on the Menu (Report List options 1 to 5).

    When the user selects an item on the Option Group Main Menu, we can test its index number in code and make its corresponding detailed menu on the Tab Control Page current.

    In the final refinement of the Menus, we will hide the Tab Pages of the Tab Control so that the Sub-Menus on them can be accessed only through the program, depending on the selection made on the Main Menu by the User.

    Code for Main Menu.

    First, the On Click Event Procedure of the Frame0 Option Group Control (Main Menu) allows the user to select the options and display their corresponding detailed Sub-Menu on the Tab Control. By default, the 1st item (Data Files) on the Main Menu is selected, and the Data Files list will be visible on the Sub-Menu.

  22. Display the Form Code Module (View -> Code) or click the Module Icon on the Toolbar Button.

  23. Copy and paste the following VBA Code into the Module:

    Private Sub Frame0_Click()
    Dim k
    k = Me![Frame0]
    Select Case k
        Case 1
            Me.TabCtl9.Pages(0).SetFocus
        Case 2
            Me.TabCtl9.Pages(1).SetFocus
        Case 3
            Me.TabCtl9.Pages(2).SetFocus
    End Select
    
    End Sub

    Trial Run of Menu.

  24. Save and close the Form named Main Switchboard.

  25. Open the Main Switchboard in a normal view.

  26. Click the 2nd option, Reports, in the Main Menu to display the Report List on the 2nd Page of the Tab Control.

  27. Try selecting other options on the Main Menu, and monitor the Submenu changes on the Tab Control Pages.

Forms Menu.

Now, we will write VBA Code similar to the above example to open Data File Forms when the User selects Options from the Sub-Menu.

  1. Open the Main Switchboard in Design View.

  2. Display the Code Module of the Form (View ->Code).

  3. Copy and paste the following VBA Code into an empty area of the Module:

    Private Sub Frame1_Click()
    Dim f1
    f1 = Me![Frame1]
    Select Case f1
        Case 1
            DoCmd.OpenForm "Employees", acNormal
        Case 2
            DoCmd.OpenForm "Orders", acNormal
        Case 3
            DoCmd.OpenForm "Order Details", acNormal
        Case 4
            DoCmd.OpenForm "Customers", acNormal
        Case 5
            DoCmd.OpenForm "Products", acNormal
    End Sub
  4. Save and Close the Main Switchboard Form.

    Macros for Report Menu.

    To run the Report Options, we will create a Macro and attach it to the Options Group Control (named Frame2) rather than using the VBA routine.

  5. Select the Macro tab in the Database window and select New to open a new Macro in the design view.

  6. You must display the Condition Column of the Macro by selecting the Toolbar Button with the Icon Image (or similar image) given below:

  7. Write the following Macro lines, as shown in the image given below, with the appropriate Parameter Values at the bottom Property Sheet for opening each Report in Print Preview/Print:

  8. Save the Macro named RptMac.

    Attach the Macro to Report Options.

  9. Open the Main Switchboard Form.

  10. Click on the 2nd Page of the Tab Control to display the Reports Option Group Menu.

  11. Click on the outer frame of the Options Group Menu to select it.

  12. Display the Property Sheet (View ->Properties).

  13. Find and click on the On Click Property to select it.

  14. Click the drop-down list at the right edge of the Property, select the RptMac name in the On-Click Event Property.

     NB: You may create another Macro/VBA Routine for the third menu and attach it to the Frame3 Option Group Menu before doing the next step.

    In the next step, we will remove the pages of the Tab Control. Transitions between tab pages can be controlled entirely through code. This creates a seamless, “magical” effect for the sub-menu, allowing different menus to appear interchangeably in the same location.

    You can further refine the sub-menus by adjusting their dimensions and positions. Ensure you apply the same settings consistently to all three sub-menus on the Tab Control pages for a uniform appearance.

    • Top
    • Left
    • Width
    • height
  15. Click the outer edge of the Tab Control (or click on the right side of the third page) to select it.

  16. Display the Property Sheet (View ->Properties).

  17. Find the Style Property in the Property Sheet and set it to None.

  18. Save and close the Main Switchboard Form.

  19. Open the Form in normal view and try out the Menu.

Share:

Digital Clock on Main Switchboard

Digital Clock on Main Switchboard.

You probably have several timekeeping devices around you—clocks, wristwatches, or even your computer—to check the current date and time. But why not add a digital clock to your project’s Main Switchboard form? This way, users can check the date and time at a glance, right in the middle of their work, without interrupting their workflow.

Beyond practicality, an animated digital clock also adds a touch of style to the Main Switchboard. All it takes is a label control on the Form and just a few lines of VBA code.

The clock automatically pauses whenever another form is opened over the Main Switchboard, and it restarts with the current time as soon as the Switchboard becomes active again.

If you’ve never used VBA in your databases and aren’t sure where to begin, this is the perfect opportunity to start with something simple, useful, and fun. Simple Clock Design.

Let us do it together.

  1. Open one of your existing Databases.

  2. If you have a Control Screen (Main Switchboard) in your database, then open it in Design View. You can open any Form in Design View to try this out.

  3. Display the Toolbox (View ->Toolbox) if it is not visible.

  4. Click the Label Tool to select.

  5. Draw a Label where you would like the Digital Clock to appear on the Form.

    For this example, I used a copy of the Main Switchboard form from the Microsoft Access sample database Northwind. The image below shows the form in Design View, with a Label control inserted for displaying the digital clock.

  6. Type at least one character (any character) in the Label control; otherwise, the Label control will disappear when you click elsewhere.

  7. While the Label Control is still in the selected state, display its Property Sheet (View ->Properties).

  8. Change the following Property Values as given below:

    • Name    =   lblClock
    • Width   =  1.5938"
    • Height   =  0.3125"
    • Border Style = Transparent
    • Font Size = 8
    • Font Weight = Bold
    • Text Align   =  Center

    Next, we need just two lines of VBA code to start the digital clock. The first line goes in the Form_Load() event procedure of the Switchboard form. This code starts the form’s IntervalTimer immediately after the Switchboard opens, ensuring the clock begins running as soon as the form is displayed.

  9. Click the form selector at the top-left corner of the form, where the horizontal and vertical rulers intersect, to select the entire form. The Property Sheet will now display the form-level properties. If the Property Sheet is closed, follow Step 7 above to reopen it and view the form’s properties.

  10. Find the On Load Property and click on it to select it.

  11. Select [EventProcedure] from the drop-down list box.

  12. Click on the Build (...) button at the right edge of the Property to open up the VBA Module with an empty skeleton of the VBA Sub-Routine as given below:

    The Form_Load() Event and Code.

    Private Sub Form_Load()
    
    End Sub
  13. Write (or copy) the following line of VBA Code in the middle of the above lines of Code:

    Me.TimerInterval = 1000 

    This line of code tells Access to pass program control to the form’s Timer subroutine (which we will write next) at one-second intervals. In other words, whatever code we place in the Timer subroutine will be executed once every second, sixty times per minute.

    In the Timer subroutine, we will add a single line of code to read the system date and time, and to update the label caption we created earlier. As a result, the label will display a continuously updating digital clock.

  14. Select Timer from the drop-down control at the top of the VBA Module Window.

    The opening and closing lines of the Timer Sub-Routine will be inserted into the VBA Module.  You must write the line given in the middle by inserting spaces and other punctuation correctly between double-quotes (date/time format string).

    Private Sub Form_Timer()
        Me.lblClock.Caption = Format(Now(), "dddd dd, mmm-yyyy hh:nn:ss")
    End Sub

    Alternatively, you can copy and paste all three lines of the VBA Code anywhere within the Form Module.

  15. Close and Save the Form.

  16. Open the Form in Normal View.

Your digital clock will show the Current Date and Time, and the time change is updated every second.

When other forms are open and overlapping the Switchboard or different programs and macros are running, the Main Switchboard Form becomes inactive. In such events, the digital clock can be temporarily turned off until the Switchboard becomes active again. This prevents unnecessary updates to the clock’s label and allows other programs to run more efficiently without interruptions from the clock’s timer.

We will write two more lines of code for the On Deactivate() and On Activate() Event Procedures to turn off the Timer (when the Main Switchboard is inactive) and to turn on (when the Main Switchboard is active again), respectively.

  1. Open the Form in Design View.

  2. Display the Form's VBA Module (View ->Code).

  3. Copy and paste the following VBA Code into an empty area of the Module.

    Private Sub Form_Activate()
        Me.TimerInterval = 1000
    End Sub
    
    Private Sub Form_Deactivate()
        Me.TimerInterval = 0
    End Sub

    Trial Run of Form Activity.

  4. Save the Form and close it.

  5. Open it in the normal view.

  6. Open some other Form overlapping the Main Switchboard.

  7. Click on the Title Area of the second Form and drag it away from the Main Switchboard Form so that you can see the Digital Clock on it.

    You can see that the clock is not getting updated.

  8. Close the second Form.

Now the Main Switchboard Form becomes active, and the Clock will start updating the Date and Time again.

Technorati Tags:
Share:

Label Animation Zoom-out Fade

Label Animation Zoom-out Fade. 

Computer programming is fascinating because once you begin experimenting, it often sparks new ideas and leads you to try even more. I originally planned to demonstrate just one or two label animation techniques, but we’ve already explored five different animation methods.

Now, we’ll learn one more trick using the same form and labels we worked with last week. All you need to do is copy the new VBA code into the Form's code module.

The sample image below shows the program in action:

In this method, the color of each letter in the employee’s name gradually fades as if receding into the distance. At the same time, the size of each letter decreases progressively. The letters are displayed at fixed time intervals, creating an animated effect with the sense of three-dimensional depth.

Links to earlier Animation Styles.

If you have not tried out the earlier Label animation methods, you may explore them by visiting the following pages:

  1. Label Animation Style-1
  2. Label Animation Style-2
  3. Label Animation Variant
  4. Label Animation Zoom-in Style
  5. Label Animation in Colors

Let us try the new method.

The Design Task.

  1. Make a copy of the Employees form we used last week. On this form, create twenty small labels, and set their Name property to the values lbl01 through lbl20.

    A sample image of the Form is given below for reference:

  2. Open the Employees Form you have copied in Design View.

  3. Display the Form's Code Module (View -> Code).

  4. Copy and paste the following VBA Code into the Module, overwriting the existing Code:

    The Form Module Code.

    Option Compare Database
    Option Explicit
    
    Dim j, txtName, ctrl As Label, i
    
    
    Private Sub Form_Current()
    Dim t, xRGB As Long, fsize
    
    txtName = UCase(Me![first name] & " " & Me![Last name])
    fsize = 22
    For j = 1 To 20
       Set ctrl = Me("lbl" & Format(j, "00"))
       ctrl.FontSize = fsize
       ctrl.Caption = ""
       fsize = fsize - 1
    Next
       
    xRGB = RGB(10, 10, 10)
    i = xRGB
    For j = 1 To Len(txtName)
       Set ctrl = Me("lbl" & Format(j, "00"))
       xRGB = xRGB + i
       ctrl.ForeColor = xRGB
       ctrl.Caption = Mid(txtName, j, 1)
       
    t = Timer
    Do While Timer < t + 0.1
      DoEvents
    Loop
    
    Next
    
    End Sub
  5. Save the Form with the Code and open it in the normal view.

  6. Use the Record Navigation buttons to move forward or backward through the records, and observe how the employee name is displayed dynamically in the form’s header.

  1. Textbox and Label Inner Margins
  2. Animating Label on Search Success
  3. Label Animation Style-1
  4. Label Animation Style-2
  5. Label Animation Variant
  6. Label Animation Zoom-in Style
  7. Label Animation in Colors
  8. Label Animation Zoom-out Fade
Share:

Label Animation in Colors

Label Animation in Colors.

We have explored several label animation methods in the previous posts, and now we will try another trick using the last design you created: the Zoom-in method.

In this method, we add a splash of color—each letter of the employee’s name is assigned a randomly generated color. The letters are plotted in a “magical” sequence: odd-numbered letters appear first on odd-numbered labels (lbl01, lbl03, lbl05, etc.), followed by even-numbered letters on even-numbered labels (lbl02, lbl04, lbl06, etc.). The letters are displayed at fixed time intervals, creating a smooth animated effect.

After these two steps, the employee’s name is fully displayed in the form header, producing an eye-catching Zoom-in animation.

If you have tried the earlier label animation methods from last week, implementing this technique will be straightforward and easy to follow.

The Design Task.

  1. Make a Copy of the Employees Form we designed last week, and name it Employees_2 or any other name you prefer.

    The sample design of the Form, with twenty labels placed close together in the Header of the Form, with the Name Property Values set as lbl01 to lbl20, is given below:

  2. Display the Form's Code Module (View -> Code) after opening the Form in Design View.

  3. Copy and paste the following VBA Code into the Form Module, overwriting the existing Code.

    The Form Module Code.

    Option Compare Database
    Option Explicit
    
    Dim j, txtName, ctrl As Label
    
    Private Sub Form_Current()
    Dim t, m, R, G, B
    Randomize (Timer)
    
    txtName = Me![first name] & " " & Me![Last name]
    For j = 1 To 20
       Set ctrl = Me("lbl" & Format(j, "00"))
       ctrl.Caption = ""
    Next
    For j = 1 To Len(txtName) Step 2
       Set ctrl = Me("lbl" & Format(j, "00"))
       R = Int(Rnd(1) * 64)
       G = Int(Rnd(1) * 128)
       B = Int(Rnd(1) * 255)
    
       ctrl.ForeColor = RGB(R, G, B)
       ctrl.Caption = Mid(txtName, j, 1)
    
    t = Timer
    Do While Timer < t + 0.1
      DoEvents
    Loop
    Next
    
    For j = 2 To Len(txtName) Step 2
       Set ctrl = Me("lbl" & Format(j, "00"))
       R = Int(Rnd(1) * 255)
       G = Int(Rnd(1) * 128)
       B = Int(Rnd(1) * 64)
    
       ctrl.ForeColor = RGB(R, G, B)
    
       ctrl.Caption = Mid(txtName, j, 1)
    
    t = Timer
    Do While Timer < t + 0.1
      DoEvents
    Loop
    
    Next
    
    End Sub
  4. Save the Form with the new VBA Code.

    The Demo Run.

  5. Open the Form in the normal view.

  6. Use the record navigation button to move the record forward or back and watch how the employee name is displayed in the header labels.

The sample screen in Normal View is given below:

    Each name character is displayed in a different color at a 0.1-second interval, creating a smooth animated effect. The color codes are generated randomly.

    In this program, we use two delay loops instead of the form’s default Timer Interval event procedure.

    You can adjust the animation speed by modifying the value in the line:

    Do While Timer < t + 0.1

    For example:

    • 0.5 will slow down the animation.

    • 0.05 will make it run faster.

    This gives you full control over the speed of the Zoom-in effect.

  1. Textbox and Label Inner Margins
  2. Animating Label on Search Success
  3. Label Animation Style-1
  4. Label Animation Style-2
  5. Label Animation Variant
  6. Label Animation Zoom-in Style
  7. Label Animation in Colors
  8. Label Animation Zoom-out Fade
Share:

Label Animation Zoom-in Style

Label Animation Zoom-in Style.

This week, we will explore a different style of label animation technique. If you would like to revisit the earlier, simpler label animation methods, the links to those pages are provided below.

In all the earlier methods, we used two labels moving toward each other from opposite directions, coming together to form text that appeared like a 3D heading.

This week, we will take a different approach. For this method, you will need about twenty small labels placed close together in a horizontal line. Each label will display a single character of the employee’s name. Since all employee names are fewer than twenty characters, this arrangement will be sufficient.

A sample layout of the labels in Design View is shown below:


Animation Style image.

The employee’s name will appear from left to right, one character at a time, across the labels. After the full name is displayed, the letters will zoom in and zoom out sequentially, creating a dynamic animated effect.

The screenshot above was captured live of this action.

The Design Task.

Let us complete the design task of this animation.

  1. If you have not explored the earlier examples, then import the Employees Table from the Northwind sample database.

  2. Click the Employees Table and select Form from the Insert Menu.

  3. Create a Form as shown above and save it named Employees.

  4. Open the Form in Design View.

  5. Select the Label Tool from the Toolbox and draw a Label control in the Form's header section.

  6. Change the following property values of the Label as given below:

    • Name = lbl01
    • Width = 0.2528"
    • Height = 0.3549"
    • Top = 0.1563"
    • Left = 1.1146
    • Back Style = Transparent
    • Border Style = Transparent
    • Special Effect = Flat
    • Font Name = Verdana
    • Font Size = 14
    • Font Weight = Bold
    • ForeColor = 7500402

    Now, we must copy this label nineteen times and arrange them as shown in the first image, at the top of this page.

  7. Change the Name Property Value of each label sequentially, lbl01, lbl02, lbl03, and so on, so that we can easily address each label in Programs to change their caption values to display the Employee's name.

  8. Right-click on the Label and select Copy from the displayed Shortcut Menu.

  9. Select Paste from the Edit Menu to create a copy of the Label.

  10. Click and drag the new label to place it to the right of the first label. Don't worry about the misalignment of the labels; we will arrange them easily later.

  11. Repeat the Paste action to create another eighteen labels.

    The Labels will appear automatically to the right of earlier labels.

  12. Click on the second Label.

  13. Display its Property Sheet (View -> Properties).

  14. Change the Name Property value to lbl02.

  15. Repeat this method for other labels, naming them sequentially as lbl03, lbl04, and so on up to lbl20.

  16. Click outside the first label (lbl01), hold the left mouse button, and drag the Mouse over the labels to select them all together.

  17. Select Format -> Align -> Top to align all Labels horizontally.

  18. Select Format -> Align -> Left to bring all the Labels close together.

    Now that we have arranged the labels and their Name Property Values to lbl01 to lbl20, all that is left to do is to copy the following Programs into the Form's Code Module.

  19. Select Code from the View Menu.

  20. Copy and paste the following VBA Code into the Module (overwriting the existing VBA Code, if any).

    The Form Module Code.

    Option Compare Database
    Option Explicit
    
    Private Const twips As Long = 1440
    Dim i, j, txtName, ctrl As Label
    
    Private Sub Form_Current()
    
    txtName = UCase(Me![first name] & " " & Me![Last name])
    i = 0
    Me.TimerInterval = 50
    
    End Sub
    
    Private Sub Form_Timer()
    Dim m, L1, L2
    i = i + 1
    If i > Len(txtName) Then
       For j = Len(txtName) + 1 To 20
        Set ctrl = Me("lbl" & Format(j, "00"))
        ctrl.Caption = ""
        Next
       Me.TimerInterval = 0
       i = 0
       animate
    Else
       Set ctrl = Me("lbl" & Format(i, "00"))
       ctrl.Caption = Mid(txtName, i, 1)
       ctrl.ForeColor = &H727272
    End If
    DoEvents
    
    End Sub
    
    Public Function animate()
    Dim k As Integer, t
    For k = 1 To Len(txtName)
      Set ctrl = Me("lbl" & Format(k, "00"))
      ctrl.ForeColor = 0
      ctrl.FontSize = 24
      DoEvents
      If k = 10 Then Exit For
      t = Timer
      Do While Timer < t + 0.09
        DoEvents
      Loop
      ctrl.FontSize = 14
    
    Next
    
    End Function

    The Trial Run.

  21. Save the Form with the Code.

  22. Open it in the normal view.

  23. Use the Record Navigation Buttons to move the record forward/back and display the employee name in animated form.

Hope you like this method better and implement it in your Projects.

  1. Textbox and Label Inner Margins
  2. Animating Label on Search Success
  3. Label Animation Style-1
  4. Label Animation Style-2
  5. Label Animation Variant
  6. Label Animation Zoom-in Style
  7. Label Animation in Colors
  8. Label Animation Zoom-out Fade
Share:

Label Animation Variant

Label Animation Variant.

I have several label animation styles lined up to share with you, and we have already explored two of them in the last two articles:

  1. Label Animation Style-1
  2. Label Animation Style-2

In this lesson, we will explore two variations of the animation method we practiced last week. If you have already followed the earlier tutorials creating the sample labels and writing the program, you can reuse the same setup with only a few small adjustments.

The only change needed is in the position of the second label (lbl2). The arrangement of labels from the previous animation method is shown below:

In this method, both labels are initially placed apart and then move toward each other until they meet at the final position, forming the 3D heading style.

If you prefer a variation with a stronger visual appeal, you can reduce the distance between the two labels and place them slightly closer together. This adjustment gives the animation a smoother and more polished effect.

The modified version of the design is shown below:

You can implement this variant of the earlier animation style by changing the Properties of the lbl2 label as given below. 

The Design Change.

  1. Make a copy of the Employees Form with the earlier animation method and change the Form name to something like Employee2_1 or any other name you prefer.

  2. Open Employee2_1 in Design View.

  3. Click on lbl2 (the White-colored label) and display its Property Sheet (View -> Properties).

  4. Change the Property Values as shown below. The only change you need to make is the left Property value. But the full Property Values are given below.

    • Width = 2.9924
    • Height = 0.3549
    • Top = 0.125
    • Left = 3.6354
    • Back Style = Transparent
    • Border Style = Transparent
    • Font Name = Verdana
    • Font Size = 18
    • Text Align = Center
    • Font Weight = Bold
    • ForeColor = #FFFFFF

    Once you make the Left Property Value change, the label will move into place as shown in the second image above.

  5. Display the Code Module of the Form (View -> Code) while the Employee2_1 Form is still in the design view.

  6. Copy and paste the following modified Code into the Form Module, overwriting the existing VBA Code.

    The Form Module VBA Code.

    Option Compare Database
    Option Explicit
    'Global declarations
    Private Const twips As Long = 1440
    Dim i, j
    
    Private Sub Form_Current()
    Dim txtName As String
    Me.lbl1.Left = 2.5194 * twips
    Me.lbl1.Top = 0.1569 * twips
    Me.lbl1.Width = 2.9924 * twips
    Me.lbl1.Height = 0.3549 * twips
    
    Me.lbl2.Left = 3.6354 * twips
    Me.lbl2.Top = 0.125 * twips
    Me.lbl2.Width = 2.9924 * twips
    Me.lbl2.Height = 0.3549 * twips
    
    txtName = UCase(Me![first name] & " " & Me![Last name])
    Me.lbl1.Caption = txtName
    Me.lbl2.Caption = txtName
    i = 0
    Me.TimerInterval = 25
    
    End Sub
    
    Private Sub Form_Timer()
    Dim m, L1, L2
    i = i + 1
    m = i Mod 2
    Select Case m
        Case 1
            L1 = Me.lbl1.Left
            L1 = L1 + (0.084 * twips)
            Me.lbl1.Left = L1
        Case 0
            L2 = Me.lbl2.Left
            L2 = L2 - (0.084 * twips)
            Me.lbl2.Left = L2
    End Select
    DoEvents
    If i > 12 Then
       Me.TimerInterval = 0
       i = 0
    End If
            
    End Sub
  7. Save the Form and open it in Normal View.

  8. Move the Employee Records forward using the record navigation buttons and watch the refined animation of employee names.

I hope you like the overall impact of the change in the earlier animation method.

The Design Changes.

We will look into another variant of the same animation method with the following design change:

  1. In this method, the label  lbl2 is placed below lbl1. Both labels are then gradually moved toward each other until they overlap, creating a 3D-style header.

  2. Make a Copy of the Employee2_1 Form and save it named Employee2_2.

  3. Open the Form in Design View.

  4. Click the label with white text to select it.

  5. Display the Property Sheet (View -> Properties) and change the following Property Values as shown below:

    • Width = 2.9924
    • Height = 0.3549
    • Top = 0.5313
    • Left = 2.5729
    • Back Style = Transparent
    • Border Style = Transparent
    • Font Name = Verdana
    • Font Size = 18
    • Text Align = Center
    • Font Weight = Bold
    • ForeColor = #FFFFFF
  6. Display the Code Module of the Form (View ->Code).

  7. Copy and paste the following Code into the Form VBA Module, overwriting the existing Code.

    The Form Module Code.

    Option Compare Database
    Option Explicit
    
    Private Const twips As Long = 1440
    Dim i, j
    
    
    Private Sub Form_Current()
    Dim txtName As String
    Me.lbl1.Left = 2.5521 * twips
    Me.lbl1.Top = 0.1569 * twips
    Me.lbl1.Width = 2.9924 * twips
    Me.lbl1.Height = 0.3549 * twips
    
    Me.lbl2.Left = 2.5729 * twips
    Me.lbl2.Top = 0.5313 * twips
    Me.lbl2.Width = 2.9924 * twips
    Me.lbl2.Height = 0.3549 * twips
    
    txtName = Me![first name] & " " & Me![Last name]
    Me.lbl1.Caption = txtName
    Me.lbl2.Caption = txtName
    i = 0
    Me.TimerInterval = 50
    
    End Sub
    
    Private Sub Form_Timer()
    Dim m, L1, L2
    i = i + 1
    m = i Mod 2
    Select Case m
        Case 0
            L1 = Me.lbl1.Top
            L1 = L1 + (0.084 * twips)
            Me.lbl1.Top = L1
        Case 1
            L2 = Me.lbl2.Top
            L2 = L2 - (0.084 * twips)
            Me.lbl2.Top = L2
    End Select
    DoEvents
    If i > 4 Then
       Me.TimerInterval = 0
       i = 0
    End If
            
    End Sub
    
    
  8. Save the Form and open it in Normal View.

  9. Move the employee records forward using the Record Navigation buttons and observe how the new animation method is applied in the same 3D style.

Next week we will learn a different and interesting label animation method.

  1. Textbox and Label Inner Margins
  2. Animating Label on Search Success
  3. Label Animation Style-1
  4. Label Animation Style-2
  5. Label Animation Variant
  6. Label Animation Zoom-in Style
  7. Label Animation in Colors
  8. Label Animation Zoom-out Fade
Share:

Label Animation Style-2

Label Animation Style-2.

Last week, we learned a simple label animation method that displayed employee names character by character from the right side of the label. This animation gave the form a lively appearance and made the screen more engaging for the user.

This week, we’ll try a different label animation method using the same set of labels. In the earlier Animation Style, we used two identical labels to create a 3D effect for the employee’s name. We’ll continue with the same design, but this time the labels will be placed horizontally apart in the layout, as shown below: 

In the Form_Current Event Procedure, the two labels will be programmed to move in opposite directions. As they gradually approach one another, they will finally align and merge together, forming a 3D-style heading as shown below:

This animation occurs every time an employee record becomes current. The labels start from their original positions, move gradually in opposite directions, and finally settle to form the 3D-style employee name.

If you have already completed the earlier label animation task, implementing this method will be straightforward. Simply adjust the following property settings for lbl1 and lbl2, and then copy the VBA routines into the Employee form’s module.

The Label Animation Design.

  1. Open your database where you have tried the earlier example.

  2. Make a copy of the earlier Employee Form. We have tried the Label Animation and named it Employee2.

  3. Open the Employee2 Form in Design View.

  4. Click on the top label in the form’s header and drag it slightly to the right. This will allow you to select each label individually and adjust its properties as needed.

  5. Select the Label named lbl1.

  6. Display its Property Sheet (View --> Properties) and set the following Property Values:

    • Name = lbl1
    • Width = 2.9924"
    • Height = 0.3549"
    • Top = 0.1569"
    • Left = 2.5194"
    • Back Style = Transparent
    • Border Style = Transparent
    • Font Name = Verdana
    • Font Size = 18
    • Text Align = Centre
    • Font Weight = Bold
    • ForeColor = 0
  7. Select the Label named lbl2.

  8. Display the Property Sheet and change the following Property Values:

    • Name = lbl2
    • Width = 2.9924"
    • Height = 0.3549"
    • Top = 0.125"
    • Left = 5.5313"
    • Back Style = Transparent
    • Border Style = Transparent
    • Font Name = Verdana
    • Font Size = 18
    • Text Align = Centre
    • Font Weight = Bold
    • ForeColor = 16777215
  9. Display the Form Module (View -> Code).

  10. Copy and paste the following VBA Code, overwriting the existing Code:

    The Form Module VBA Code.

    Option Compare Database
    Option Explicit
    
    Private Const twips As Long = 1440
    Dim i, j
    
    Private Sub Form_Current()
    Dim txtName As String
    Me.lbl1.Left = 2.5194 * twips: Me.lbl1.Top = 0.1569 * twips: Me.lbl1.Width = 2.9924 * twips: Me.lbl1.Height = 0.3549 * twips
    Me.lbl2.Left = 5.5313 * twips: Me.lbl2.Top = 0.125 * twips: Me.lbl2.Width = 2.9924 * twips: Me.lbl2.Height = 0.3549 * twips
    txtName = Me![first name] & " " & Me![Last name]
    Me.lbl1.Caption = txtName
    Me.lbl2.Caption = txtName
    i = 0
    Me.TimerInterval = 5
    
    End Sub
    
    Private Sub Form_Timer()
    Dim m, L1, L2
    i = i + 1
    m = i Mod 2
    Select Case m
        Case 0
            L1 = Me.lbl1.Left
            L1 = L1 + (0.084 * twips)
            Me.lbl1.Left = L1
        Case 1
            L2 = Me.lbl2.Left
            L2 = L2 - (0.084 * twips)
            Me.lbl2.Left = L2
    End Select
    DoEvents
    If i > 35 Then
       Me.TimerInterval = 0
       i = 0
    End If
            
    End Sub
  11. Save the Employee2 Form.

  12. Open the Employee2 Form in normal view

  13. Click on the Record Navigation control to advance each record forward one by one.

    For each record change, you will find the Employee Name Labels move towards each other and assemble into place to form a 3D heading.

  1. Textbox and Label Inner Margins
  2. Animating Label on Search Success
  3. Label Animation Style-1
  4. Label Animation Style-2
  5. Label Animation Variant
  6. Label Animation Zoom-in Style
  7. Label Animation in Colors
  8. Label Animation Zoom-out Fade
Share:

Label Animation Style-1

Label Animation Style-1.

A form with lively elements—such as animated command buttons, GIFs, or moving text—makes working with MS Access applications more interesting for users. However, MS Access does not provide these features out of the box. To create dynamic elements, we must rely on our imagination and ingenuity, using the standard tools available in Access.

After working with MS Access for a while, I grew tired of repeatedly using the same static objects in application designs. I wanted to create something more eye-catching to make the experience more engaging. As the saying goes, “Necessity is the mother of invention.” This led me to develop several creative features, including: 

Today, we will learn a simple label animation technique using an example from the Employees form in the Northwind.mdb sample database.

  1. Import the following objects from the Northwind sample database.:

    • Table: Employees
    • Form: Employees

    If you open the Employees form in Normal View, you’ll see that the employee’s full name—first name and last name combined—is displayed in the form header within a text box. When you navigate to a different record, the full name in the header updates automatically.

    We will enhance this by adding an animated effect: the employee name appears character by character, moving slowly from the right edge of the label to the left, then settling into place.

  2. Open the Employees Form in Design View.

  3. Delete the existing TextBox that displays the Employee's Name.

  4. Create a Label on the Header Section of the Form.

  5. Display the Property Sheet (View -> Properties) of the Label and change the following Property Values:

    • Name = lbl1
    • Width = 3.5"
    • Height =0.32"
    • Back Style = Transparent
    • Border Style = Transparent
    • ForeColor = 16777215
    • Font Name = Times New Roman
    • Font Size = 18
    • Font Weight = Bold
    • Text Align = Right
  6. Display the Code Module of the Form (View ->Code).

  7. Press Ctrl+A to select and highlight the existing VBA Routines and press the Del key to delete them.

  8. Copy the following VBA Code and paste it into the Code Module of the Form.

    Label Animation Code.

    Option Compare Database
    Option Explicit
    
    Dim txt1 As String, txtlen As Integer
    Dim j As Integer, txt2 As String
    
    Private Sub Form_Timer()
    j = j + 1
    If j <= txtlen Then
      txt2 = Left(txt1, j)
      Me.lbl1.Caption = txt2
      'Me.lbl2.Caption = txt2
      Else
      Me.TimerInterval = 0
    End If
    
    End Sub
    
    
    Private Sub Form_current()
           
    txt1 = UCase(Me![FirstName] & " " & Me![LastName])
    txtlen = Len(txt1)
    j = 0
    Me.TimerInterval = 50
    
    End Sub
  9. Save and Close the Employees Form.

  10. Open the Employees Form in the normal view.

  11. When you open the form, the employee name will gradually move into place from right to left, appearing character by character in the header label.

  12. Click the forward Navigation records button to move the records one by one.

  13. The employee names will be displayed in the same style by moving from the right edge of the label to the left.

Fancy Work to the Label.

We will add a little fancy work to the Employee Name for a three-dimensional backlit effect by copying the Label and placing it over the existing one. See the finished design of the image given below:

  1. Open the Employee Form in Design View.

  2. Select the header label.

  3. Create a copy of the header label.

  4. Display the Label's Property Sheet (View ->Properties).

  5. Change the following Property Values as shown below:

    • Name = lbl2
    • ForeColor = 128
  6. Place the copied label above the first label, slightly down and to the left from the top and left edge, respectively. The sample image design view is given below:

  7. I have already included the line of code necessary to run this trick.  All you have to do is enable that line in the VBA code and do the following:

  8. While the Form is still in design view, display the VBA Module (View ->Code)

  9. You will find the following line of code in the Sub Form_Timer() Event Procedure in a different color (most probably in green color):

  10. 'Me.lbl2.Caption = txt2

  11. Find the ' (single quote) character at the beginning of this line and delete it.

  12. Save and Close the Form.

  13. Open the Form in the Normal View.

    Now you will find the Employee Names appearing in animated characters and in 3D style, as shown in the second image above.

  1. Textbox and Label Inner Margins
  2. Animating Label on Search Success
  3. Label Animation Style-1
  4. Label Animation Style-2
  5. Label Animation Variant
  6. Label Animation Zoom-in Style
  7. Label Animation in Colors
  8. Label Animation Zoom-out Fade
Share:

PRESENTATION: ACCESS USER GROUPS (EUROPE)

Translate

PageRank

Post Feed


Search

Popular Posts

Blog Archive

Powered by Blogger.

Labels

Forms Functions How Tos MS-Access Security Reports msaccess forms Animations msaccess animation Utilities msaccess controls Access and Internet MS-Access Scurity MS-Access and Internet External Links Queries Array Class Module msaccess reports Accesstips msaccess tips WithEvents Downloads Objects Menus and Toolbars MsaccessLinks Process Controls Art Work Collection Object Property msaccess How Tos Combo Boxes ListView Control Query VBA msaccessQuery Calculation Dictionary Object Event Graph Charts ImageList Control List Boxes TreeView Control Command Buttons Controls Data Emails and Alerts Form Custom Functions Custom Wizards DOS Commands Data Type Key Object Reference ms-access functions msaccess functions msaccess graphs msaccess reporttricks Command Button Report msaccess menus msaccessprocess security advanced Access Security Add Auto-Number Field Type Form Instances ImageList Item Macros Menus Nodes Recordset Top Values Variables msaccess email progressmeter Access2007 Copy Excel Expression Fields Join Methods Microsoft Numbering System RaiseEvent Records Security Split SubForm Table Tables Time Difference Utility WScript Workgroup Wrapper Classes database function msaccess wizards tutorial Access Emails and Alerts Access Fields Access How Tos Access Mail Merge Access2003 Accounting Year Action Animation Attachment Binary Numbers Bookmarks Budgeting ChDir Color Palette Common Controls Conditional Formatting Data Filtering Database Records Defining Pages Desktop Shortcuts Diagram Disk Dynamic Lookup Error Handler Export External Filter Formatting Groups Hexadecimal Numbers Import Labels List Logo Macro Mail Merge Main Form Memo Message Box Monitoring Octal Numbers Operating System Paste Primary-Key Product Rank Reading Remove Rich Text Sequence SetFocus Summary Tab-Page Union Query User Users Water-Mark Word automatically commands hyperlinks iSeries Date iif ms-access msaccess msaccess alerts pdf files reference restore switch text toolbar updating upload vba code