Microsoft KB Archive/210356

From BetaArchive Wiki

Article ID: 210356

Article Last Modified on 4/22/2003



APPLIES TO

  • Microsoft Access 2000 Standard Edition



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).


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


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


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



Additional query words: concatenation

Keywords: kbhowto kbinfo kbprogramming KB210356