Converting String to Number via Code VBA SQL Server MS Access

Posted on 2006-05-12
Last Modified: 2008-02-01
I am scanning a barcode that reads into a textbox as follows..


I have a Sql Server where the value is being stored..

it is saved into the DB as

9090972, the field is a number datatype

Later on, I am scanning the barcode again to do some things, this value has to be compared against the earlier stored value in the DB (9090972)

I have been fooling around with the CInt function, to convert a string to a integer..but I am getting an overflow error.

How do you codewise convert  a string to a integer, in other words ...I want

09090972   -->  9090972

CInt function won't work..

Any help or insight would be much appreciated

Question by:nomar2
    LVL 65

    Accepted Solution

    CLng(YourNumber) = 9090972, when YourNumber = 09090972  

    The Access interger is +/- 32,767.  The Access Long Integer is equivalent to the SQL Server Integer.
    LVL 44

    Assisted Solution

    If the barcode is 09090972, I don't think you should be saving it as a number which drops the leading zero(es).  That leading zero has significance and there may be serveral.  Once it is in the DB as a string, the next time it has to be compared to something, it is done directly, without conversion!

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now