|
Subject:
|
Zeros at left...
|
|
Posted By:
|
comicghozt
|
Post Date:
|
10/2/2006 5:22:56 AM
|
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.
|
|
Reply By:
|
mmcdonal
|
Reply Date:
|
10/2/2006 7:46:28 AM
|
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
|
|
Reply By:
|
comicghozt
|
Reply Date:
|
10/2/2006 10:28:17 AM
|
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!
|
|
Reply By:
|
echovue
|
Reply Date:
|
10/2/2006 10:33:22 AM
|
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
|
|
Reply By:
|
mmcdonal
|
Reply Date:
|
10/2/2006 11:18:16 AM
|
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
|
|
Reply By:
|
mmcdonal
|
Reply Date:
|
10/2/2006 11:19:25 AM
|
Also, what I was saying before, is accept the number value without the leading zeroes, then display it with them, as Mike suggests.
mmcdonal
|
|
Reply By:
|
mmcdonal
|
Reply Date:
|
10/2/2006 11:21:50 AM
|
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
|
|
Reply By:
|
comicghozt
|
Reply Date:
|
10/3/2006 2:27:51 AM
|
The masl wont work. I will work on that condition programing.
Thank you both!
|