Link to home
Start Free TrialLog in
Avatar of maverick0728
maverick0728Flag for United States of America

asked on

Excel VBA transfer recordset to csv file

I have a recordset object that I want to transfer to a .csv file.
Here is the code I have that is returning data to the "result" object.  I need to take the "result" object and save it to a UNC path csv file.
Private Sub cmdMoveToERP_Click()
  On Error GoTo ErrHandler
  If OnNetwork = True Then
    Dim data As New clsADOwrapper
    Dim strSQL As String
    Dim result As Object


   strSQL = "SELECT QuoteNum, QuoteLine, AssemblySeq, PartNum, IndentedPartNum, Description, RevisionNum, QtyPer, IUM, Parent, PriorPeer, NextPeer, Child, BomSequence, "
   strSQL = strSQL & "BomLevel , RequiredQty FROM dbo.EstAsmTemp "
   strSQL = strSQL & "WHERE QuoteNum = '" & Sheets("Initialization").Range("B2").Value & "' "
   strSQL = strSQL & "AND QuoteLine = '" & Sheets("Initialization").Range("H2").Value & "' "
   Set result = data.cGetRecordset(CONN_STR, strSQL)
   
   'MsgBox (CInt(result.RecordCount))

'HERE NEED TO MOVE result OBJECT TO CSV FILE
   

     
  Else
    MsgBox "Not Connected to Network"
    Exit Sub
  End If
   
ErrHandler:
  Set data = Nothing
  Exit Sub
   
End Sub

Open in new window

Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

ok, so what object is cGetRecordset returned? is it a ADODB.Recordset object?
Avatar of maverick0728

ASKER

correct, a ADODB.Recordset object
ASKER CERTIFIED SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
works.  thanks.