473,407 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Left Padding of "0" in String

overcomer
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
Nov 13 '08 #1

✓ answered by missinglinq

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

Format(YourNumericField, "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

YourNumericField

equals 10

and in VBA code you use the formula

NewNumber = Format(YourNumericField, "0000") * 12

Access will correctly calculate NewNumber as 120.

If you try to use

Format(YourNumericField, "0000")

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

Val(Format(YourNumericField, "0000"))

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

2 92076
missinglinq
3,532 Expert 2GB
Padding a number with leading zeros can be done using the Format() function:

Format(YourNumericField, "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

YourNumericField

equals 10

and in VBA code you use the formula

NewNumber = Format(YourNumericField, "0000") * 12

Access will correctly calculate NewNumber as 120.

If you try to use

Format(YourNumericField, "0000")

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

Val(Format(YourNumericField, "0000"))

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)>
Nov 13 '08 #2
Hi,

thanks for the reply... i already have the solutions for both questions... thanks a lot... :)
Nov 19 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: cjl | last post by:
Hey all: I want to convert strings (ex. '3', '32') to strings with left padded zeroes (ex. '003', '032'), so I tried this: string1 = '32' string2 = "%03s" % (string1) print string2 >32
3
by: Jordan Peterson | last post by:
When using {list-style: none} to hide the bullets in a <ul>, the bullets disappear but they are still accounted-for when positioning text. Specifically, I have: <div style='text-align:...
6
by: Dan | last post by:
I wish to replace all the occurrances of " with &quot; within a string. I have tried using myString.Replace("\"", "&quot;"), but this does not work Any suggestions will be greatly appreciated ...
50
by: Shadow Lynx | last post by:
Consider this simple HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 STRICT//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head>...
8
by: Ulysse | last post by:
Hello, I need to clean the string like this : string = """ bonne mentalit&eacute; mec!:) \n <br>bon pour info moi je suis un serial posteur arceleur dictateur ^^* \n ...
2
by: Angus | last post by:
I am trying to change the selection in Javascript - but this HTML element is not a standard option control. On the web page it looks like a dropdown list - and you click on the right hand down...
1
by: manchin2 | last post by:
Hi, Can anybody please provide the information about "&quot" and its use, if possible please provide an example. ...
2
by: jmash | last post by:
Suppose I have the following string whch is part of an xml string: String s= "Script Id=&quot;Test&quot; " And I need to get s= "Script Id="Test" " Can anyone tell me how this can acheived? ...
10
by: Anze | last post by:
Hmmm... anyone? :) Anze Anze wrote:
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.