PDA

Click to See Complete Forum and Search --> : Visual Basic to Access to Excel


StevenH
Nov 15th, 2000, 10:35 PM
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

jp_schwartz
Nov 16th, 2000, 09:25 AM
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.

StevenH
Nov 16th, 2000, 01:47 PM
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