Select to view content in your preferred language

RecordSet Export to csv

2022
1
06-23-2016 12:24 PM
IngridHogle
Frequent Contributor

I am trying to use the Recordset Export method to export a shapefile's .dbf to a .csv file. The .csv file gets created, but then ArcPad crashes...and the .csv file is empty. Here is my code, which I call OnSetActive of a page. If I comment out the pRS.Export line, no .csv file is created and ArcPad does not crash. But I need a .csv file with the data as my output.

Can anyone troubleshoot this or perhaps share a snippet of code where they were able to successfully use the Recordset's Export method, so I can see what I am doing wrong?

Sub CreateCSV()   

    '++ create the recordset object

    Dim pRS

    Set pRS = Application.CreateAppObject("RecordSet")

    '++ create a shapefile and add a field

    Call pRS.Create ("Y:\Prep\ArcPadPrep\DATACHECKS\Testing.shp", apShapePoint)

    Call pRS.Fields.Append ("LfNodes", apFieldNumeric)

    '++ Open new shapefile, add a feature, set the value of the field LfNode to 1, update and close

    pRS.Open "Y:\Prep\ArcPadPrep\DATACHECKS\Testing.shp",2

    pRS.AddNew

    pRS.Fields("LfNodes").Value = 1

    pRS.Update

    pRS.Close

    '++ export Testing.dbf to Testing.csv

    pRS.Export "Y:\Prep\ArcPadPrep\DATACHECKS\Testing.csv",-1

    '++ clean up

    Set pRS = Nothing

End Sub

0 Kudos
1 Reply
RebeccaStrauch__GISP
MVP Emeritus

I don't know if this will help, but maybe try putting ( )  around the args for th pRS.Open and pRS.Export  ??  just a quick observations ....nothing tested.

0 Kudos