Consulting

Results 1 to 3 of 3

Thread: Help me on this issue....

  1. #1

    Smile Help me on this issue....

    hi

    I am trying to copy data from one excel sheet to another using ADODB Connection. I am able to fetch the data except one field. Even if it has value it gives me empty string.

    [VBA]set con = new abodb.connection//First excel
    set con1 = new abodb.connection//second excel
    set rs = new adodb.recordset
    set rs1 = new adodb.recordset //second excel
    //i declared the connection string
    cn.open
    cn1.open
    squery= "select * from [Sheet1$]"
    rs1.open squery,cn1,adlockoptimistic,adopendynamic
    rs.open squery,cn,adlockoptimistic,adopendynamic
    rs.movefirst
    do until rs.EOF
    if(IsNull(rs.Fields(2)) = True) then
    goto L1
    else
    rs1.fields(1) = rs.fields(1)
    rs1.fields(2) = rs.fields(2)
    rs1.fields(3) = rs.fields(3)
    rs1.update
    rs1.movenext
    endif
    L1:
    rs.movenext
    loop[/VBA]

    In this case rs.Fields(2) creates the problem. If it does not has any data it return Null value and if it has data in the cell then it return "" empty string value. Kindly help me on this issue. For the rest of the fields i am getting information and for the second field i am getting empty string instead of valid data...help me on this issue
    Last edited by Bob Phillips; 08-03-2011 at 06:21 AM. Reason: Added VBA tags

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,455
    Location
    Can you post the two workbooks for us to try it with?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3

    Smile Hi

    I cant do that...It is confidential file..

    If i try with sample information it works fine.
    If i try with huge data.it strucks to print the info..
    I changed the Format property to General,Text,Number etc...But it is not working...

Posting Permissions

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