mikewood1980
Registered User.
- Local time
- Today, 16:50
- Joined
- May 14, 2008
- Messages
- 45
Hi
I have the following code:
The code crashes at the point marked (rsWallCons.MoveFirst) - the message box above shows 0 records. So far, this makes sense, except that there should be records in rsWallCons. Even more strangely, the records that should be in there are deleted successfully by the following SQL statements. Given that the code doesnt get this far I don't know how this happens???! Does anybody know why this might be - I'm completely confused!
Just to recap - I need to now a) why there are apparently no records in rsWallCons b) why the SQL statements execute before they should and c) if the are no records in rsWallCons - how do the SQL statements delete the right records??!
Thanks in advance for your help
Mike
I have the following code:
Code:
Dim rsWallCons As Recordset
sQuery = "select * from tblWallConstructions where ((tblWallConstructions.chrTestID) like '*" & Me.cboReportID & "*')"
Set rsWallCons = dbcurr.OpenRecordset(sQuery)
MsgBox ("matching wall constructions = " & rsWallCons.RecordCount)
rsWallCons.MoveFirst <<<<<CRASHES HERE !!!!
Do Until rsWallCons.EOF
'delete linings
DoCmd.RunSQL ("delete * from tblLining where ((tblLining.intLiningID) = " & rsWallCons!intLiningID1 & ")")
DoCmd.RunSQL ("delete * from tblLining where ((tblLining.intLiningID) = " & rsWallCons!intLiningID2 & ")")
MsgBox ("should have deleted linings...")
'delete wall leaves
DoCmd.RunSQL ("delete * from tblWallLeaves where ((tblWallLeaves.intWallLeavesID) = " & rsWallCons!intLeafID1 & ")")
DoCmd.RunSQL ("delete * from tblWallLeaves where ((tblWallLeaves.intWallLeavesID) = " & rsWallCons!intLeafID2 & ")")
'then delete that record...
rsWallCons.Delete
rsWallCons.MoveNext
Loop
The code crashes at the point marked (rsWallCons.MoveFirst) - the message box above shows 0 records. So far, this makes sense, except that there should be records in rsWallCons. Even more strangely, the records that should be in there are deleted successfully by the following SQL statements. Given that the code doesnt get this far I don't know how this happens???! Does anybody know why this might be - I'm completely confused!
Just to recap - I need to now a) why there are apparently no records in rsWallCons b) why the SQL statements execute before they should and c) if the are no records in rsWallCons - how do the SQL statements delete the right records??!
Thanks in advance for your help
Mike