Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / May 2008

Tip: Looking for answers? Try searching our database.

How do I remove leading zeros?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frank Martin - 18 May 2008 04:36 GMT
I have downloads from the bank including
check numbers containing leading zeros.

eg 0002356, where what I want is just 2356.

How do I enter formatting in the query column
to get rid of these leading zeros?
Please help, Frank
Vsn - 18 May 2008 07:34 GMT
I do suppose your 'bank supplied number' is a text string.

You could do this straigh, like below:-

Using Val([fBankNumber])

SELECT tblBankNumbers.fID, tblBankNumbers.fBankNumber, Val([fBankNumber]) AS
Clean
FROM tblBankNumbers
WITH OWNERACCESS OPTION;

Or using a function (witch could be more flexible and give more control if
needed):-

SELECT tblBankNumbers.fID, tblBankNumbers.fBankNumber,
ReturnNum([fBankNumber]) AS Clean
FROM tblBankNumbers
WITH OWNERACCESS OPTION;

Function ReturnNum(stgX As String) As Long
   ReturnNum = Val(stgX)
End Function

Success,
Ludovic

>I have downloads from the bank including check numbers containing leading
>zeros.
[quoted text clipped - 4 lines]
> zeros?
> Please help, Frank
Frank Martin - 19 May 2008 07:06 GMT
Thanks, but if I use your first method I get
"#error"  in any blank fields.

I find that if I put "nnnn" in the criteria
field, this works OK; at least for my
application.

>I do suppose your 'bank supplied number' is
>a text string.
[quoted text clipped - 34 lines]
>> column to get rid of these leading zeros?
>> Please help, Frank
Vsn - 19 May 2008 07:48 GMT
Sorry, I did not allow for blank fields (blank cheque numbers?), you could
do so as follows:-

IIF(IsNull([fBankNumber]),0,Val([fBankNumber]))

Which wil result in a 0 for a blank field.

Anyhow, if you managed to get to your target, your done.

Ludovic

> Thanks, but if I use your first method I get "#error"  in any blank
> fields.
[quoted text clipped - 36 lines]
>>> leading zeros?
>>> Please help, Frank
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.