P
Phil Hood
Hello,
I have attached the following code to the 'After Update'
event of a control on a form. However, I get an error
message:
"Run Time Error 3027 - Can't update. Database or object is
read only."
I think it might be something to do with the fact that the
select statement uses two tables but I'm not sure?
Any help would be greatly appreciated.
Thanks
Phil.
-----------------------------------------------------
Dim dbsCurrent As Database
Dim rstHeatBonusPoints As Recordset
Dim strQuerySQL As String
Dim rstHomeFirstAndSecond As Recordset
Dim strQuerySQL2 As String
Set dbsCurrent = CurrentDb
strQuerySQL = "SELECT * FROM Results WHERE [Results]!
[HeatID]= " & _
[Forms]![Heat edit]![HeatID] & ";"
Set rstHeatBonusPoints = dbsCurrent.OpenRecordset
(strQuerySQL)
rstHeatBonusPoints.MoveFirst
Do Until rstHeatBonusPoints.EOF
rstHeatBonusPoints.Edit
rstHeatBonusPoints!BonusPoints = 0
rstHeatBonusPoints.Update
rstHeatBonusPoints.MoveNext
Loop
Forms![Heat edit].Refresh
rstHeatBonusPoints.Close
dbsCurrent.Close
Set dbsCurrent = CurrentDb
strQuerySQL2 = "SELECT * FROM Results, RiderMatch WHERE
((([Results]![HeatID]) = " & _
[Forms]![Heat edit]![HeatID] & ") And (([Results]!
[Result]) = 3) And (([Results]![RiderID]) = [RiderMatch]!
[RiderID]) And (([RiderMatch]![ridingPosition]) < 9)) Or
((([Results]![HeatID]) = " & [Forms]![Heat edit]![HeatID]
& ") And (([Results]![Result]) = 2) And (([Results]!
[RiderID]) = [RiderMatch]![RiderID]) And (([RiderMatch]!
[ridingPosition]) < 9))ORDER BY Results.Result;"
Set rstHomeFirstAndSecond = dbsCurrent.OpenRecordset
(strQuerySQL2)
If Not (rstHomeFirstAndSecond.EOF And
rstHomeFirstAndSecond.BOF) Then
rstHomeFirstAndSecond.MoveFirst
rstHomeFirstAndSecond.Edit
rstHomeFirstAndSecond!BonusPoints = 1
rstHomeFirstAndSecond.Update
End If
-----------------------------------------------------
I have attached the following code to the 'After Update'
event of a control on a form. However, I get an error
message:
"Run Time Error 3027 - Can't update. Database or object is
read only."
I think it might be something to do with the fact that the
select statement uses two tables but I'm not sure?
Any help would be greatly appreciated.
Thanks
Phil.
-----------------------------------------------------
Dim dbsCurrent As Database
Dim rstHeatBonusPoints As Recordset
Dim strQuerySQL As String
Dim rstHomeFirstAndSecond As Recordset
Dim strQuerySQL2 As String
Set dbsCurrent = CurrentDb
strQuerySQL = "SELECT * FROM Results WHERE [Results]!
[HeatID]= " & _
[Forms]![Heat edit]![HeatID] & ";"
Set rstHeatBonusPoints = dbsCurrent.OpenRecordset
(strQuerySQL)
rstHeatBonusPoints.MoveFirst
Do Until rstHeatBonusPoints.EOF
rstHeatBonusPoints.Edit
rstHeatBonusPoints!BonusPoints = 0
rstHeatBonusPoints.Update
rstHeatBonusPoints.MoveNext
Loop
Forms![Heat edit].Refresh
rstHeatBonusPoints.Close
dbsCurrent.Close
Set dbsCurrent = CurrentDb
strQuerySQL2 = "SELECT * FROM Results, RiderMatch WHERE
((([Results]![HeatID]) = " & _
[Forms]![Heat edit]![HeatID] & ") And (([Results]!
[Result]) = 3) And (([Results]![RiderID]) = [RiderMatch]!
[RiderID]) And (([RiderMatch]![ridingPosition]) < 9)) Or
((([Results]![HeatID]) = " & [Forms]![Heat edit]![HeatID]
& ") And (([Results]![Result]) = 2) And (([Results]!
[RiderID]) = [RiderMatch]![RiderID]) And (([RiderMatch]!
[ridingPosition]) < 9))ORDER BY Results.Result;"
Set rstHomeFirstAndSecond = dbsCurrent.OpenRecordset
(strQuerySQL2)
If Not (rstHomeFirstAndSecond.EOF And
rstHomeFirstAndSecond.BOF) Then
rstHomeFirstAndSecond.MoveFirst
rstHomeFirstAndSecond.Edit
rstHomeFirstAndSecond!BonusPoints = 1
rstHomeFirstAndSecond.Update
End If
-----------------------------------------------------