L
luanhoxung
Hi, All !
I have a trouble with delete some record though VBA,
I need delete some record in "many" table with relationship 'one-
many'.
The Error coming is: "Cannot Update. Database or Object is read-ony"
Can anybody help me here! I know less VBA !
Thanks in advance.
Here is the code:
Dim Delrs as DAO.Recordset
Dim StrDel as string
StrDel = "SELECT DISTINCTROW Tremaishipment.SOHD, Tremaishipment.MAHH
FROM Thopdongxuat INNER JOIN (Tchitiethdx INNER JOIN Tremainshipment
ON (Tchitiethdx.MAHH = Tremainshipment.MAHH) AND (Tchitiethdx.SOHD =
Tremainshipment.SOHD)) ON Thopdongxuat.SOHD = Tchitiethdx.SOHD" _
& " GROUP BY Tremainshipment.SOHD, Tremainshipment.MAHH,
Tchitiethdx.SLUONG, Thopdongxuat.SAISO" _
& " having ((Sum(Tremainshipment.SLUONG))<=[tchitiethdx].
[sluong]*[thopdongxuat].[saiso]);"
Set Delrs = CurrentDb.OpenRecordset(StrDel)
If Delrs.RecordCount > 0 Then
Delrs.Delete
Delrs.Update
End If
Set rsT = Nothing
I have a trouble with delete some record though VBA,
I need delete some record in "many" table with relationship 'one-
many'.
The Error coming is: "Cannot Update. Database or Object is read-ony"
Can anybody help me here! I know less VBA !
Thanks in advance.
Here is the code:
Dim Delrs as DAO.Recordset
Dim StrDel as string
StrDel = "SELECT DISTINCTROW Tremaishipment.SOHD, Tremaishipment.MAHH
FROM Thopdongxuat INNER JOIN (Tchitiethdx INNER JOIN Tremainshipment
ON (Tchitiethdx.MAHH = Tremainshipment.MAHH) AND (Tchitiethdx.SOHD =
Tremainshipment.SOHD)) ON Thopdongxuat.SOHD = Tchitiethdx.SOHD" _
& " GROUP BY Tremainshipment.SOHD, Tremainshipment.MAHH,
Tchitiethdx.SLUONG, Thopdongxuat.SAISO" _
& " having ((Sum(Tremainshipment.SLUONG))<=[tchitiethdx].
[sluong]*[thopdongxuat].[saiso]);"
Set Delrs = CurrentDb.OpenRecordset(StrDel)
If Delrs.RecordCount > 0 Then
Delrs.Delete
Delrs.Update
End If
Set rsT = Nothing