Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2005
    Posts
    29

    Smile Unanswered: converting to number and insert number

    Hi need hel again. I have a column in the access table that contain text. i have a few record with text like this 100,000,000.00K. The problem now is i want to convert them to numbers where the K indicate to add three more zero (100,000,000,000.00) before the decimal place. So can i input any code in query to do this or there is a way to write VB code to solve the problem. Appreciate the help. Thanks.

  2. #2
    Join Date
    Jan 2005
    Posts
    68
    this function will convert the number.

    Public Function FormatNumber(varNumber As Variant)
    Dim tmp As Variant
    If Right(varNumber, 1) = "K" Then
    tmp = CDbl(Left(varNumber, Len(varNumber) - 1))
    FormatNumber = tmp * 1000
    End If
    End Function

    hope it helps.

  3. #3
    Join Date
    Feb 2005
    Posts
    29
    Hey thanks frosty1, Thanks for your help...anyway i solve the problem using query but it was a long process. Anyway thanks...will try using the code. But how to connect this piece of code to the table? Sorry i'm a newbie so do not no how the process. Is it using module? then link up with the form?

  4. #4
    Join Date
    Jan 2005
    Posts
    68
    you put the function into a public module (not your form module). then any time you need to convert a number in your code just call the function like this example which would convert a textbox that had your number:

    textbox=FormatNumber(textbox.value)

    hope this helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •