 |
| Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 2nd, 2006, 05:22 AM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Zeros at left...
Hello.
Normaly, when we type a number wich the first digit is a 0 (zero) on a cell with "number" as data type, when you hit 'enter' we loose that zero, wright?
Is there a way to keep that zero without changing the data type?
I've tryed changing proprieties but nothing worked.
Please help.
Thanx.
|
|

October 2nd, 2006, 07:46 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
I don't think there is a way to do this. Why do you need to maintain the 0?
If the 0 needs to be there, then this probably isn't really a number data type. Only use a number data type when you need to do arithmetic or mathematic calculations on the field. It sounds like this is used for something else.
Your option is to use two fields:
First field is text field, and the 0 will be preserved.
Second field is number field used for calculations. Hide this field, and populate it from the text field using code "CInt()"
Does this help?
mmcdonal
|
|

October 2nd, 2006, 10:28 AM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanx mmcdonal.
That can not be done.
There's commercial management program called Winmax that uses an Access table for all the lists(products, clients,...) and I can not "touch it". I tried to change the data type for that ID column and I got an error in the program.
The point is that each client has a code and some of those dodes start with a 0. If I apply it to the software 0's are lost and so it wont match with other programs and tables we work with too.
So I guess there's nothing I can do about it...
Thanx anyway!
|
|

October 2nd, 2006, 10:33 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
I'm not sure if this will work, but what about changing the format of the number when it is displayed? if you need a 10 digit number, a mask like "0000000000" should let you keep the leading zeros - at least when it is displayed - it will still store the value in the table as just a regular number sans the leading zeros
Mike
Mike
EchoVue.com
|
|

October 2nd, 2006, 11:18 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Code this, then:
Where sCustID = the string value "0001234"
and iCustID = the number value 1234
If Right(sCustID, Len(iCustID)) = iCustID Then
...
End If
This will compare the two values without the zeroes as used in number fields.
Does this help?
mmcdonal
|
|

October 2nd, 2006, 11:19 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Also, what I was saying before, is accept the number value without the leading zeroes, then display it with them, as Mike suggests.
mmcdonal
|
|

October 2nd, 2006, 11:21 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Actually, you might have to do this:
If Right(sCustID, Len(iCustID)) = CStr(iCustID) Then
...
End If
Or
Dim sCustID As String
Dim iCustID As Integer
Dim cCustID As String
cCustID = CStr(iCustID)
If Right(sCustID, Len(cCustID)) = cCustID Then
...
End If
I am used to retyping in VBScript, which doesn't work so well in VBA.
mmcdonal
|
|

October 3rd, 2006, 02:27 AM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The masl wont work.
I will work on that condition programing.
Thank you both!
|
|
 |