Select to view content in your preferred language

Writing to dbf file

1885
8
10-04-2010 10:46 PM
CharlesHuxtable
Emerging Contributor
Can anyone help?
My problem is this: I've created a vegetation survey form in ArcPad which contians a subform that I want to export to a dbf file not connected to the shapefile of the main survey form. I can get the subform to open OK and can enter the data, but when I click on a button with a control for exporting the data to a dbf file, I get an error message. I'm at a loss as to what the problem is. The script is below. I get an error message for line 24: "theRS.MoveNext 'moves to last record"

Sub SetID
'Sets the unique ID for each survey
If ThisEvent.Object.Mode = 3 Then
ThisEvent.Object.Pages("General1").Controls("OID").Text = CStr(CLng(DateDiff("s",CDate(#01/01/2005#), Now)))
End If

End Sub


Sub OpenSubFormLandCover
'Opens the Land Cover Form from the Landuse Form
Application.Map.Layers("Landuse").Forms("frmLndCov").Show
End Sub

Sub SaveCloseSubFormLandCover

             Set page = editform.pages.item("Lnduse1")

'open the DBF-file
Set theRS = Application.CreateAppObject("RecordSet")

theRS.Open "P:\Work\SSD\Users\Huxtac\ArcPad Stuff\Veg Survey\LandCoverOut.dbf",2

theRS.MoveNext 'moves to last record
theRS.AddNew 'adds a new record

theRS.Fields("OID").Value = layer.Forms("EDITFORM").Pages("General1").Controls("OID")
theRS.Fields("SITE").Value = layer.Forms("EDITFORM").Pages("General1").Controls("Site")
theRS.Fields("DOMUSE").Value = layer.Forms("frmLndCov").Pages("Lnduse1").Controls("CboDomLndUse")
theRS.Fields("UPPER").Value = layer.Forms("frmLndCov").Pages("Lnduse1").Controls("CboLndCovUpp")
theRS.Fields("GROUND").Value = layer.Forms("frmLndCov").Pages("Lnduse1").Controls("CboLndCovGrd")
theRS.Update 'saves information to the recordset
theRS.Close
Set theRS = Nothing
Application.Map.Layers("Landuse").Forms("frmLndCov").Close
End Sub


Does anyone have any ideas
Tags (3)
0 Kudos
8 Replies
JimMeuse
Deactivated User
I am doing exactly the same thing, the code is identical to yours with the exception of theRS.MoveNext line; I simply add the new record.  Try commenting out line 24.

Jim
0 Kudos
CharlesHuxtable
Emerging Contributor
Jim, I tried what you suggested and commented out line 24, but get the following error message for line Line 25 of script: "Microsoft VB Script runtime error. Permission denied, Line 25 Column 2. Source Text Unavailable".

The error for Line24 was "Error Source Unavailable. Error Description Unavailable. Line 24, Column 2. Source Text Unavailable

I was wondering if I need to write some script into the ArcPad APX file to allow ArcPad to talk to the dbf file? I was also wondering if the database file which I created for receiving the written data from Arcpad was somehow the wrong format - I created it in Excel, but Maybe ArcCatalogue would be better
0 Kudos
JimMeuse
Deactivated User
I have also got similar messages in the past.  Is the DBF file read-only?  You should not have to do anything fancy here.

Jim
0 Kudos
CharlesHuxtable
Emerging Contributor
I got it to work - not sure what I did wrong initially but all good now. Thanks for your help
0 Kudos
BBulla
by
Regular Contributor
I'm pretty sure that RS.MoveNext will throw an error if there are no records in the dbf, so the first time you try to populate the dbf you will get this error.  You need to make sure there is a record in there to begin with. 

But you don't really need it in there anyways, so removing it and just going straight to RS.AddNew should be fine.
0 Kudos
AdAdhikary
New Contributor
Can anyone help?

I just changed excel file to a dbf file and imported to Arc GIS. (I had test.xlsx) which I converted to (test.dbf) by changing the extension. I imported to Arc GIS. However I cannot write on this dbf file. It would be great if any one can tell me how to write
in this dbf file inside ARC GIS.


Thanks

Ad
0 Kudos
BBulla
by
Regular Contributor
I'm pretty sure you can't just rename a file to .dbf and have it work.

Try exporting the one you renamed out of ArcMap and call it test2.dbf, and then try editing that one.

From my experience, the only .dbf that will work in ArcMap or ArcPad is one that is created directly out of an ESRI product.
0 Kudos
AdAdhikary
New Contributor
Thanks Bulla for replying the message

However when I try to export test1.dbf , I got error "There was an error exporting the table, Create output table failed"

I have attached test1.dbf (ideally as said earlier i want to write on test1.dbf)

could you be able to send a remedy

thanks

Ad
0 Kudos