View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
keawee[_2_] keawee[_2_] is offline
external usenet poster
 
Posts: 1
Default Nedd help on my function in VBA

Hello,

I would like to have your assistance on a problem of VBA. I recover
since Access a cross query that I insert in Excel. My problem is that I
make an external joint in my cross query and that it create me
automatically a field.

My Problem: I have a field which is named < in my query. It is
possible to remove this field in my Recordset?. In sum up, when my
recordset meets a data of this field then < it removes the data.

I can delete or hide the column but i would like to find an other
solution.

Here my code:

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("Module")
With Sh
Set Rg = .Range("A8")
End With

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

Set Rs1 = Db1.OpenRecordset("REPORTING: Database", dbOpenDynaset)

Rg.CurrentRegion.Clear

If Rs1.EOF = False Then

Nb = Rs1.Fields.Count - 1

'-- I display the field name <--
For a = 0 To Nb
Rg(, 1 + a) = Rs1.Fields(a).Name
Next

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

Rg.Offset(1).CopyFromRecordset Rs1

Else

MsgBox "No Record."
End If


Set Rg = Nothing: Set Sh = Nothing

Rs1.Close: Db1.Close

Set Rs1 = Nothing: Set Db1 = Nothing
End Sub


Thanks for your help

Keawee



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