Hi,
I have code on my close button (on the main form) that is running through a loop to ensure that a particular field is filled on the subform. when it finds an offending record I want it to go to that record on the subform. My loop code is working find and finding the offending records but I am having trouble then getting it to go the that record on the subform. I have tried
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
but that is not working and I am guessing it is because me. is not the form that it relates to but when I try Me!Subformname.bookmark it says method not found.
Is there a simple way to do this????
Here is all my code
Private Sub Close_Click()
On Error GoTo Err_Close_Click
'Check that movement dates have been entered on stock delivered
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("SELECT * FROM tblStockMovementDetail WHERE RefID = " & Me.RefID)
Do Until rst.EOF
With rst
rst.Edit
If rst!QtyDelivered <> 0 And IsNull(rst!MovementDate) Then
MsgBox "Please ensure all Dates Delivered have been entered", vbOKOnly, "QuoteIT"
' Find the record that matches the control.
Dim rs As Object
Set rs = rst.Clone
rs.FindFirst "[MovementDetailID] = " & rst.MovementDetailID
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
GoTo Exit_Close_Click:
End If
End With
rst.Update
rst.MoveNext
Loop
'Close recordset
rst.Close
Set rst = Nothing
Set dbs = Nothing
DoCmd.Close
Exit_Close_Click:
Exit Sub
Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click
End Sub
Regards
tjs32
I have code on my close button (on the main form) that is running through a loop to ensure that a particular field is filled on the subform. when it finds an offending record I want it to go to that record on the subform. My loop code is working find and finding the offending records but I am having trouble then getting it to go the that record on the subform. I have tried
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
but that is not working and I am guessing it is because me. is not the form that it relates to but when I try Me!Subformname.bookmark it says method not found.
Is there a simple way to do this????
Here is all my code
Private Sub Close_Click()
On Error GoTo Err_Close_Click
'Check that movement dates have been entered on stock delivered
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("SELECT * FROM tblStockMovementDetail WHERE RefID = " & Me.RefID)
Do Until rst.EOF
With rst
rst.Edit
If rst!QtyDelivered <> 0 And IsNull(rst!MovementDate) Then
MsgBox "Please ensure all Dates Delivered have been entered", vbOKOnly, "QuoteIT"
' Find the record that matches the control.
Dim rs As Object
Set rs = rst.Clone
rs.FindFirst "[MovementDetailID] = " & rst.MovementDetailID
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
GoTo Exit_Close_Click:
End If
End With
rst.Update
rst.MoveNext
Loop
'Close recordset
rst.Close
Set rst = Nothing
Set dbs = Nothing
DoCmd.Close
Exit_Close_Click:
Exit Sub
Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click
End Sub
Regards
tjs32