Select to view content in your preferred language

Editing dbf file records

639
0
03-31-2011 03:57 PM
CharlesHuxtable
Emerging Contributor
Hi, I am developing an ArcPad form associated with a shapefile (apl file) to edit records from a database file. I want to be able to scroll forwards and backwards through the records in the database file and have the values from 2 fields from each record, "GENUS" and "SPECIES", populate two field on the Editform called "Genus" and "Species". I obtained and modified some code from an earlier thread which enables you to scroll forwards or backwards through records, displaying the record fileds in a messagebox.
My question is: How can I modify the code below to have the values diplayed in the relevant fields on the Editform, rather than in a messagebox? This would then allow me to edit the values and then save the new values back to the database file.

If possible, I would also like to be able to generate a new record in the database file using a button on the same editform. At the moment I have this capacity on another form, but would like to have it on the same form as the edits. The "Genus" and "Species" controls on the editform are comboboxes, the "Species" menu being dependant on what is selected from the "Genus" menu.

The script for the 2 subs to scroll forwards and backwards is shown below.

Sub MyScriptForwards
'Scrolls forwards through records in dbf file "FloristicsOut.dbf".
'Called from the Onclick event on a "scroll forward" button on the editform


Dim objDBF, strGenus, strSpecies, i
Set objDBF = Application.CreateAppObject("recordset")
objDBF.Open "P:\Work\SSD\Users\Huxtac\ArcPad Stuff\Veg_16\Output Files\FloristicsOut.dbf", 1
objDBF.MoveFirst
For i = 0 to objDBF.RecordCount - 1
strGenus = objDBF.Fields("GENUS").Value
strSpecies = objDBF.Fields("SPECIES").Value
msgbox ("Genus: " & strGenus & vbnewline & "Species: " & strSpecies)
objDBF.MoveNext
Next
objDBF.Close
Set objDBF = Nothing
End Sub

Sub MyScriptBackwards
'Scrolls backwards through records in dbf file "FloristicsOut.dbf".
'Called from the Onclick event on a "scroll backwards" button on the editform

Dim objDBF, strGenus, strSpecies, i
Set objDBF = Application.CreateAppObject("recordset")
objDBF.Open "P:\Work\SSD\Users\Huxtac\ArcPad Stuff\Veg_16\Output Files\FloristicsOut.dbf", 1
objDBF.MoveLast
For i = 0 to objDBF.RecordCount - 1
strGenus = objDBF.Fields("GENUS").Value
strSpecies = objDBF.Fields("SPECIES").Value
msgbox ("Genus: " & strGenus & vbnewline & "Species: " & strSpecies)
objDBF.MovePrevious
Next
objDBF.Close
Set objDBF = Nothing
End Sub


I'm not very good at VB scripting so any pointers would be gratefully received!
Tags (3)
0 Kudos
0 Replies