Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Create a Dot Leader Between Fields


View products that this article applies to.

This article was previously published under Q210356
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

↑ Back to the top


Summary

This article shows you how to create a sample user-defined Visual Basic for Applications function that you can use to create lists of fields with dot leaders between the items. For example, given the items "John" and "Doe," the function creates the following:
John.....................................Doe

↑ Back to the top


More information

To create a dot leader (or any other leader) between fields, you must use a function to make sure that the field columns line up. The Dots() function demonstrates how to create dot leaders between fields.

NOTE: For multiple lines of characters to line up correctly, you must use a fixed-width font (such as Courier) in the text boxes.

The Dots() Function

  1. Start Microsoft Access 2000, and then open any database.
  2. In the Database window, click Forms, and then click New.
  3. In the New Form dialog box, click Design View, and then click OK.
  4. Add three text box controls with the following properties to the form:
    Name: Field0
    DefaultValue: "John"
    
    Name: Field2
    DefaultValue: "Doe"
    
    Name: Field4
    Width: 2.5"
    ControlSource: =[Field0] & Dots([Field2]) & [Field2]
    					
  5. Create a new module, and then type the following line in the Declarations section:
    Option Explicit
    					
  6. Type the following procedure:
    Function Dots (ByVal Title)
       ' Set LineLen to the gap you want (in characters) between the
       ' Field0 data and the beginning of the Field2 data.
       Const LineLen = 40
    
       ' Set FillChar to the leader character you want to use between the
       ' fields.
       Const FillChar = "."
    
       Dots = String$(LineLen - Len(Title), ".")
    End Function
    					
  7. On the File menu, click Close and Return to Microsoft Access.
  8. On the View menu, click Form View. Note that Field4 contains:
    John.....................................Doe

↑ Back to the top


References

For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:
212536� OFF2000: How to Run Sample Code from Knowledge Base Articles

↑ Back to the top


Keywords: KB210356, kbprogramming, kbinfo, kbhowto

↑ Back to the top

Article Info
Article ID : 210356
Revision : 3
Created on : 4/22/2003
Published on : 4/22/2003
Exists online : False
Views : 373