I have a table that I have added two new fields to and I am trying to update the fields with the results of a function that I call LatLongCalc.
The table structure for tblHeader1 is as follows
s_GUID Autonumber
Contractor Text
Lease Text
Latitude Double
Longitude Double
County Text
State Text
I have created a form with the above fields on it and a cmdButton to run the update. I pass the function the county and state which have text values and xlat and xlong which are null in the table initially, but returned from the function. My code is as follows:
Private Sub cmdMapCounty_Click()
Dim dbs As Database
Dim rst As Recordset
Dim tdf As TableDef
Dim xlat As Double, xlong As Double
'Open the MS Access database
Set dbs = CurrentDb
'Create a TableDef object.
Set tdf = dbs.TableDefs("tblHeader1"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
'Create the Recordset object
Set rst = dbs.OpenRecordset("tblHeader1", dbOpenTable)
With rst
Do Until rst.EOF
Call LatLongCalc(County, State, xlat, xlong)
With rst
.Edit
![Latitude] = xlat
![Longitude] = xlong
.Update
End With
.MoveNext
Loop
End With
Set rst = Nothing
End Sub
My problem is that the function will run, but I am not always sure where the update will go, and then it will not advance to the next record.
Thanks for your help.
BusMgr
The table structure for tblHeader1 is as follows
s_GUID Autonumber
Contractor Text
Lease Text
Latitude Double
Longitude Double
County Text
State Text
I have created a form with the above fields on it and a cmdButton to run the update. I pass the function the county and state which have text values and xlat and xlong which are null in the table initially, but returned from the function. My code is as follows:
Private Sub cmdMapCounty_Click()
Dim dbs As Database
Dim rst As Recordset
Dim tdf As TableDef
Dim xlat As Double, xlong As Double
'Open the MS Access database
Set dbs = CurrentDb
'Create a TableDef object.
Set tdf = dbs.TableDefs("tblHeader1"
'Create the Recordset object
Set rst = dbs.OpenRecordset("tblHeader1", dbOpenTable)
With rst
Do Until rst.EOF
Call LatLongCalc(County, State, xlat, xlong)
With rst
.Edit
![Latitude] = xlat
![Longitude] = xlong
.Update
End With
.MoveNext
Loop
End With
Set rst = Nothing
End Sub
My problem is that the function will run, but I am not always sure where the update will go, and then it will not advance to the next record.
Thanks for your help.
BusMgr