A
Abbey Normal
Hi. I don't know if this is possible to do this the way I am doing it, but I
need to update the status of the order header by checking the status of the
order details.
I am using a recordset within a recordset? It is erroring out saying "End
with without with" Here is my code, and if it looks like I don't know what I
am doing, you'd be right! I copied code that I had from something else and
modified it.
Can anyone help? Thank you.
Private Sub Command0_Click()
On Error GoTo ErrorHandler
'Uses a DAO recordset
Dim db As DAO.Database
Dim rst As DAO.RecordSet
Dim rstd As DAO.RecordSet
Dim strSQL As String
Dim strSQLd As String
Dim Count As Integer
Set db = CurrentDb
'select the order headers
strSQL = "SELECT orderid,orderstatus from Orders where orderstatus
<>'complete'"
Set rst = db.OpenRecordset(strSQL)
With rst
Do Until .EOF
strSQLd = "SELECT orderid,status from [order details] where orderid =
orders.orderid"
Set rstd = db.OpenRecordset(strSQLd)
Count = 0
'order details recordset anyohter status than blank or null means
its still open
With rstd
Do Until .EOF
If Status <> " " Then Count = 1
If IsNull(Status) Then Count = 1
End With
'The above line is where it's stopping
.Edit
If Count = 1 Then order.orderstatus = "OPEN"
If Count = 0 Then order.orderstatus = "complete"
.Update
.MoveNext
Loop
.Close
End With
Exit Sub
need to update the status of the order header by checking the status of the
order details.
I am using a recordset within a recordset? It is erroring out saying "End
with without with" Here is my code, and if it looks like I don't know what I
am doing, you'd be right! I copied code that I had from something else and
modified it.
Can anyone help? Thank you.
Private Sub Command0_Click()
On Error GoTo ErrorHandler
'Uses a DAO recordset
Dim db As DAO.Database
Dim rst As DAO.RecordSet
Dim rstd As DAO.RecordSet
Dim strSQL As String
Dim strSQLd As String
Dim Count As Integer
Set db = CurrentDb
'select the order headers
strSQL = "SELECT orderid,orderstatus from Orders where orderstatus
<>'complete'"
Set rst = db.OpenRecordset(strSQL)
With rst
Do Until .EOF
strSQLd = "SELECT orderid,status from [order details] where orderid =
orders.orderid"
Set rstd = db.OpenRecordset(strSQLd)
Count = 0
'order details recordset anyohter status than blank or null means
its still open
With rstd
Do Until .EOF
If Status <> " " Then Count = 1
If IsNull(Status) Then Count = 1
End With
'The above line is where it's stopping
.Edit
If Count = 1 Then order.orderstatus = "OPEN"
If Count = 0 Then order.orderstatus = "complete"
.Update
.MoveNext
Loop
.Close
End With
Exit Sub