I have a DB that was written in Access 2000 and works fine, when I try to run in 2003 it doesn't work properly. I tried to run the conversion from 2003 and it didn't fix the issue. The issue is with a form that has several controls (textboxes, checkboxes and comboboxes) I have 3 tables, one for Staff Data, one for Incident data and one for information on Staff in Incident data. I want to check and see if the data has been changed in any of the controls and if so, ask the user if he wants to save the changes. It looks like my problem lies in a function to save the data. I have a couple of functions that are called in this function, they are:
glbstrActiveLogNumber 'is used to get the currently selected incident log number
glbstrActiveIDNumber 'is used to get the currently selected Staff member
ControlPresent "is used to check if there is a field name that matches the control (Control names are the same as relevant field names)
And here is the code that is not working and seems to be the root of the problem:
In 2000 this works fine, in 2003 I get an error message:
Run time Error 3218; Could not update, currently locked.
Any suggestions and any other quirks between the two versions that I should look for?
glbstrActiveLogNumber 'is used to get the currently selected incident log number
glbstrActiveIDNumber 'is used to get the currently selected Staff member
ControlPresent "is used to check if there is a field name that matches the control (Control names are the same as relevant field names)
And here is the code that is not working and seems to be the root of the problem:
Code:
Private Function SaveData()
Dim myControl As Control
Dim myField As Field
Dim rstStaff As Recordset
Dim rstIncidents As Recordset
Set rstIncidents = CurrentDb.OpenRecordset(QuerytblOffense)
rstIncidents.FindFirst "[LogNum] = '" & glbstrActiveLogNumber & "'"
If (rstIncidents.NoMatch = False) Then
rstIncidents.Edit
For Each myField In rstIncidents.Fields
If (ControlPresent(myField.Name, Me)) Then
Set myControl = Me.Controls(myField.Name)
If (myControl.Tag = "IncidentData") Then
rstIncidents(myControl.Name) = myControl
End If
End If
Next myField
rstIncidents.Update
End If
Set rstStaff = CurrentDb.OpenRecordset(QueryStaffInIncident)
rstStaff.FindFirst "[IDNum]='" & glbstrActiveIDNumber & "'"
If (rstStaff.NoMatch = False) Then
rstStaff.Edit
For Each myField In rstStaff.Fields
If (ControlPresent(myField.Name, Me)) Then
Set myControl = Me.Controls(myField.Name)
If (myControl.Tag = "StaffData") Then
rstStaff(myControl.Name) = myControl
End If
End If
Next myField
[highlight]rstInmates.Update 'Error Here [/highlight]
End If
Call RefreshMe
End Function
In 2000 this works fine, in 2003 I get an error message:
Run time Error 3218; Could not update, currently locked.
Any suggestions and any other quirks between the two versions that I should look for?