+ Reply to Thread
Results 1 to 5 of 5

VBA Excel & ADO Connection Changing numbers into integers

  1. #1
    Registered User
    Join Date
    02-05-2014
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2010
    Posts
    4

    VBA Excel & ADO Connection Changing numbers into integers

    I have a vba code that connects and pulls information from AS400, but for some reason it changes my field ((GLPMF.GLMP01) as amount) to an integer instead of a decimal. For example the amount I should be getting is 619.60 but it pulls in 619.00. Is there a way to fix this? Part of my code is below.

    Thanks,

    Dan






    '-----------------------------------------------------------------------------------
    'Variables Declaration
    '-----------------------------------------------------------------------------------

    Dim SQL_Text As String
    Dim cnnConn As ADODB.Connection
    Dim rstRecordset As ADODB.Recordset
    Dim cmdCommand As ADODB.Command
    Dim SQL_Insert_01 As Variant


    '-----------------------------------------------------------------------------------
    ' Open the connection.
    '-----------------------------------------------------------------------------------





    Set cnnConn = New ADODB.Connection
    With cnnConn
    .ConnectionString = _
    "DSN=WRIDATA; UID=" & UserName & "; PWD=" & Password & ";"
    .Open
    End With
    '-----------------------------------------------------------------------------------
    'SQL
    '-----------------------------------------------------------------------------------


    SQL_Text = _
    "SELECT GLPMF.GLMCO,GLPMF.GLMPJ, GLPMF.GLMGL, GLPGL.GLGLNM, GLPMF.GLMBK, GLPMF.GLMFY,sum(GLPMF.GLMP01)as amount " & _
    " FROM WRI2.GLPMF GLPMF INNER JOIN WRI2.GLPGL GLPGL ON GLPMF.GLMGL = GLPGL.GLGL " & _
    " WHERE (GLPMF.GLMCO IN ('225')" & ") AND (GLPMF.GLMBK IN ('ACT')" & ") AND (GLPMF.GLMFY=114) " & _
    " GROUP BY GLPMF.GLMCO,GLPMF.GLMPJ, GLPMF.GLMGL, GLPGL.GLGLNM, GLPMF.GLMBK, GLPMF.GLMFY "


    'MsgBox (SQL_Text)



    '-----------------------------------------------------------------------------------
    ' Open the recordset.
    '-----------------------------------------------------------------------------------

    Set rs = New ADODB.Recordset
    Set rs.ActiveConnection = cnnConn
    rs.Open SQL_Text
    '-----------------------------------------------------------------------------------
    'Retrieves the data to the sheet. The sheet should be called "Sheet1"
    '-----------------------------------------------------------------------------------

    Sheets("Data GL").Cells(2, 1).CopyFromRecordset (rs)
    Sheets("Data GL").Activate

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: VBA Excel & ADO Connection Changing numbers into integers

    cross post from other forum http://www.mrexcel.com/forum/excel-q...-integers.html
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Registered User
    Join Date
    02-05-2014
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: VBA Excel & ADO Connection Changing numbers into integers

    I posted that yesterday and I didn't get an answer so I was hoping to find an answer here.

    Thanks

  4. #4
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: VBA Excel & ADO Connection Changing numbers into integers

    according to forum rules:

    8. Don't cross-post without a link. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post. Expect cross-posts without a link to be closed.

  5. #5
    Registered User
    Join Date
    02-05-2014
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: VBA Excel & ADO Connection Changing numbers into integers

    ok, sorry. I am new to asking question on forums.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 05-15-2015, 04:12 PM
  2. Activex connection problems, connection jumps if a second Excel file is opened.
    By rdl201 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-30-2013, 09:45 AM
  3. [Macro] Excel Query Connection with Inputbox for changing filters
    By JohnGaltnl in forum Access Programming / VBA / Macros
    Replies: 0
    Last Post: 07-19-2011, 04:24 AM
  4. Whole numbers (integers) shown as decimals
    By Melanie2705 in forum Excel General
    Replies: 2
    Last Post: 06-29-2011, 02:08 PM
  5. Rounding numbers to specific integers
    By Kagemucha in forum Excel General
    Replies: 4
    Last Post: 11-05-2006, 02:23 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1