Unanswered: Form connection (ADO) in Access 2002 error
I have a form in access 2002, which is tied to data from a remote mdb database file on a server. I am using the following code to connect the form to the data.
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim dbs As DAO.Database, rsta As DAO.Recordset, sql, datapath As String
Set dbs = CurrentDb
sql = "SELECT * FROM Data_Location"
Set rsta = dbs.OpenRecordset(sql, dbOpenDynaset)
datapath = .Fields("Data Location").Value
.Provider = "Microsoft.access.OLEDB.10.0"
.Properties("data provider").Value = "Microsoft.Jet.OLEDB.4.0"
.Properties("data source").Value = datapath
Dim rst As String
rst = "SELECT * FROM [Land_Sales]"
Set rs = New ADODB.Recordset
Set .ActiveConnection = cn
.Source = rst
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
Set Me.Recordset = rs
Set rs = Nothing
Set cn = Nothing
The form connects to the data just fine, and I can make manual edits to the form and the data is saved. I can also add new records to the form and they save fine as well. My form is automated, in that it will take values inputed and calculate other values and fills in applicable form fields. When I am using the automation features built into the form for a new record, they work just fine, but when I'm trying to edit a current record the database shuts down on me every time an automation procedure is triggered. I open the same database in Access 2003 and it works just fine, no problems.
Can anyone help me figure out what's going wrong and what I can do to right it? I obtained the code above from microsoft's website, the address is: