Results 1 to 4 of 4

Thread: [RESOLVED] Help putting numeric values in Access Database

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    12

    Resolved [RESOLVED] Help putting numeric values in Access Database

    I am not too good with databases and this one has been giving me a headache for the past 2 days. I have an access database with only 2 fields of data; the Date, and a Number Field. When I debug the form there is nothing wrong and it inputs all data correctly, however, when I set it as a mdi child I get the following error:

    Code:
    Failed to convert parameter value from a String to a Decimal.
    The data is put into the date is using this:
    Code:
    Date.Now.ToString("MM/dd/yyyy hh:mm tt")
    and it words perfectly

    The data that is put into the number is this:
    Code:
    Textbox.Text
    I get the error when the database executes this, even though it is a textbox it only houses integers.

    I am confused

  2. #2
    Addicted Member
    Join Date
    Oct 2006
    Location
    Chennai, India
    Posts
    198

    Re: Help putting numeric values in Access Database

    Try converting the content of textbox to the required type. Like Cint, Clng.......

    Even though the value inside the Textbox is integer it is assumed as string.

    Cint(Text1.Text) for retrieving it from control.
    Regards
    Srinivasan Baskaran
    India

  3. #3
    Hyperactive Member Greyskull's Avatar
    Join Date
    Dec 2003
    Location
    somewhere in England
    Posts
    382

    Re: Help putting numeric values in Access Database

    before you start converting text input you might want to check if the input is numeric
    Then i would do what cheenu_vasan said into something like:

    Code:
    dim strTxt As String
    dim intNum As Integer
    
    strTxt = Textbox1.text
    if (isNumeric(strTxt)  = true) then
      intNum = val(strTxt) ' could use intNum = Cint(strTxt)
    end if
    ps i havent tested this code but it shud work ok..
    Please go to the Thread Tools menu and click Mark Thread Resolved when your post is answered
    If someone helped you today then please consider rating their post.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    12

    Re: Help putting numeric values in Access Database

    Ok, that 2 methods should of worked but my entire connection setup was wrong. It was not referenced in the form I was working on so it was not reading any of the values. After making the oleconnection in the current form it worked perfectly. Thanks guys!

Posting Permissions

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



Click Here to Expand Forum to Full Width