Left Padding of "0" in String

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • overcomer
    New Member
    • Nov 2008
    • 25

    Left Padding of "0" in String

    Hi....

    Please advise on how to create dynamic left padding for string... thanks to you..

    Also, if anyone could add any idea of cascading combo box as it's not possible to setup rowsource in vba.

    syntax for access 2003 can be ...

    thanks so much
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    Padding a number with leading zeros can be done using the Format() function:

    Format(YourNume ricField, "0000")

    8 will be returned as 0008, 12 as 0012 and so forth.

    Note that Format() actually returns a string/text value. Access is often forgiving when dealing with this kind of thing. If, for example

    YourNumericFiel d

    equals 10

    and in VBA code you use the formula

    NewNumber = Format(YourNume ricField, "0000") * 12

    Access will correctly calculate NewNumber as 120.

    If you try to use

    Format(YourNume ricField, "0000")

    and get an "Error 13 - Type Mismatch" error, wrap the function like this

    Val(Format(Your NumericField, "0000"))

    Originally posted by overcomer
    If anyone could add any idea of cascading combo box as it's not possible to setup rowsource in vba.
    ***Why*** can't you set the Row Source in VBA? It doesn't require a lot of code, but I know of no way to set up cascading comboboxes using no code at all.

    Welcome to Bytes!

    Linq ;0)>

    Comment

    • overcomer
      New Member
      • Nov 2008
      • 25

      #3
      Hi,

      thanks for the reply... i already have the solutions for both questions... thanks a lot... :)

      Comment

      Working...