Hi all,
I've got a program that transfers information from my datagrid to excel. It works PERFECTLY for a database of less than 40 rows. BUT more than 40 gives a 6148 runtime error!?!?!?! I'm been looking at this thing all day! HELP!

Where there's an arrow it shows what VB deems as my error.


'get total number of fields
Dim total_columns As Integer 'counter for total number of columns
Dim total_rows As Integer 'counter for total number of rows
'get total number of columns
total_columns = MY_AdoRecSet.Fields.Count
'get total number of rows
total_rows = MY_AdoRecSet.RecordCount

'Go through the X and Y axes to enter the datagrid information into the
'excel worksheet. The loop goes through the column then the next row.

Dim current_row As Integer
Dim current_column As Integer
For current_row = 1 To total_rows Step 1
----> MY_grid.Row = current_row - 1 'select the row in the grid
For current_column = 1 To total_columns Step 1
MY_grid.Col = current_column - 1 'select the column in the grid
If action = PRINTER Then
MY_xl_worksheet.Cells(current_row + Yoffset + 1, _
current_column + Xoffset).Value = MY_grid.Text
Else
MY_xl_worksheet.Cells(current_row + Yoffset, _
current_column + Xoffset).Value = MY_grid.Text
End If
Next
Next
If action = PRINTER Then
Call print_setup(MY_xl_worksheet, MY_combobox)
'Print out the Information
MY_xl_worksheet.PrintOut
End If
If action = FILE Then
If IsMissing(path) Then
MsgBox "path name not defined"
End
Else
Call saveXLS(MY_xl_worksheet, path)
End If
End If
printgrid = 0
Exit Function