View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
keawee[_4_] keawee[_4_] is offline
external usenet poster
 
Posts: 1
Default My code replace the data by the line number

Hello, I have a problem in a recordset.

I recover of the data since Access and I insert my data in Excel. I
place my data in A11 for example and imagine that my data go from A11
to R51. With each time, in my column A with last the recordings it me
insert not data but the number of the line, in this case 51.

I have only this problem that in a cell and the first column of my last
recording. Could you help me?.

This is my code

Public Sub CopyFromRecordset()
Dim Db1 As Database
Dim Rs1 As Recordset, Nb As Long
Dim Sh As Worksheet, Rg As Range, Nl As Range
Dim Chemin As String, Fichier As String

Dim bordure As MsoLineStyle

bordure = msoLineSingle

Set Sh = Worksheets("Test")
With Sh
Set Rg = .Range("A10")
End With

Set Db1 = DBEngine.OpenDatabase(ThisWorkbook.Path
& "\GeneralReport.mdb")

Set Rs1 = Db1.OpenRecordset("REPORT", dbOpenDynaset)

Rg.CurrentRegion.Clear

If Rs1.EOF = False Then

Nb = Rs1.Fields.Count - 1

For a = 0 To Nb
Rg(, 1 + a) = Rs1.Fields(a).Name
Next

Rg.Resize(, Nb + 1).Font.Bold = True
Rg.Resize(, Nb + 1).Interior.ColorIndex = 15


Rg.Offset(1).CopyFromRecordset Rs1

Else
MsgBox("No Record")
End If

After I kill the object
....

Thanks for your help

Keawee



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/