I have a DB that was written in Access 2000 that works. When I try to run it in Access 2003 it doesn't work. I tried to convert it from 2003 but that did not fix the problem. The form has several controls (text boxes, checkboxes and combo boxes) The form controls are populated from the result of queries from cascading combo boxes. The controls have TAG info to identify the table that the data is derived from. The form is then checked to see if any of the controls are "dirty". The problem seems to lie in the code to save the data. The code has a few functions that it calls, they are:
glbstrActiveLogNumber [color #ff0000]'This is used to get the currently selected Incident Log Number[/color]
glbstrActiveIDNumber[color #ff0000] 'This is used to get the currently selected Staff member[/color]
ControlPresent [color #ff0000] 'This is used to see if the control has a corresponding Field name (the controls are named the same as relevant Field names)[/color]
And the code that is not working is:
The data doesn't get saved when run in 2003? Any suggestions and any other quirks I need to be on the look out for?
glbstrActiveLogNumber [color #ff0000]'This is used to get the currently selected Incident Log Number[/color]
glbstrActiveIDNumber[color #ff0000] 'This is used to get the currently selected Staff member[/color]
ControlPresent [color #ff0000] 'This is used to see if the control has a corresponding Field name (the controls are named the same as relevant Field names)[/color]
And the code that is not working is:
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] rstStaff.Update[/highlight]'This doesn't write the data
End If
Call RefreshMe
End Function
The data doesn't get saved when run in 2003? Any suggestions and any other quirks I need to be on the look out for?