aziz rasul
Active member
- Local time
- Today, 07:18
- Joined
- Jun 26, 2000
- Messages
- 1,935
I have the following snippet of code which works if strAccumulateHazards does not contain any apostrophe's. However if it does then I get an error in strSQL below. How do I amend the code to prevent such an error?
Code:
Set rstAccumulateHazards = CurrentDb.OpenRecordset("tblTemp4", dbOpenDynaset)
With rstAccumulateHazards
Do While Not .EOF
If .AbsolutePosition = 0 Then
strAccumulateHazards = !hazard
Else
strAccumulateHazards = strAccumulateHazards & vbCrLf & !hazard
End If
.MoveNext
Loop
.Close
Set rstAccumulateHazards = Nothing
End With
strSQL = "UPDATE tblLandParcels SET tblLandParcels.Hazards = '" & strAccumulateHazards & "' WHERE (((tblLandParcels.Hazards) Is Null Or (tblLandParcels.Hazards)='') AND ((tblLandParcels.LongLPID)='" & strLandParcelID & "'));"
CurrentDb.Execute strSQL