Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bookmark record in subform from mainform

Status
Not open for further replies.

tjs32

Programmer
Jun 21, 2004
26
AU
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
 
Hi
Me!SubformControlName.Form.Bookmark
But you must make sure that SubformControlName is the name of the control, rather that the name of the form contained; they are not always the same.
 
Thank you, that did it. I find it difficult to know when it needs the .form and when it doesn't.

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top