Results 1 to 3 of 3

Thread: Visual Basic to Access to Excel

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    98

    Exclamation

    Hello all,

    I condcuting a search in VB and my results are placed into a .mdb

    In Visual Basic, I have the records of the search results pass to excel. The only problem I encounter is if i have ten records that are displayed from cell a10 to a20....
    I need to display more records four spaces after the last record .. so in other words I need to display my other results at cell a24... The last cell from thefirst set of records can not be determined untl the query is cmplete...

    Can anyone make a suggestion or add onto what I have:

    Here it is...

    rsRecords.MoveFirst
    For i = 0 To rsRecords.RecordCount - 1
    myWorksheet.Cells(i + 8, 1) = rsRecords("Lastname").Value
    If rsRecords.EOF = True Then Exit For
    rsRecords.MoveNext
    Next i

    This will display the records one after the other that works fine



    Steve

  2. #2
    Hyperactive Member
    Join Date
    Nov 2000
    Location
    Mexico City
    Posts
    306

    Question

    Explain yourself a little bit.
    Do you have two recordsets? Is its so, use a simple variable to know where your last row was printed.
    If things were easy, users might be programmers.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    98

    Thumbs up Great Idea

    That is great idea!!

    Never thought of that.

    rsRecords.MoveFirst
    For i = 0 To rsRecords.RecordCount - 1
    myWorksheet.Cells(i + 8, 1) = rsRecords("Lastname").Value
    If rsRecords.EOF = True Then Exit For
    rsRecords.MoveNext
    Next

    Yes I do have two recorsets that will be displayed.. above is the first recordset and the second needs to be displayed
    four spaces after the last record of the first recordset

    The solution would be to: (Correct me where I am wrong please)

    How can I determine where the last record is?

    After this I would display the value in the variable and then I would do this with the second recordset

    Dim Temp as String


    rsRecords.MoveFirst


    For i = 0 To rsRecords.RecordCount - 1
    myWorksheet.Cells(temp + 4) = rsRecords("Lastname").Value
    If rsRecords.EOF = True Then Exit For
    rsRecords.MoveNext
    Next


    Is this right? This is the code I am using can you help me with the code please?

    Steve







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