using Bookmark in Subform

J

Jens Hofmeier

Hello,

i've got a mainform with a subform. The subforms contains a combobox
(cmb_PName)
that is used to search for a recor and if it is not found, to create a new
record and set it as the current record in the subform.
I use following code AfterUpdate of the combobox:

Set rst=CurrentDB.openrecordset("SELECT * FROM myTab")
With rst
.MoveFirst
.FindFirst ("Pname='" & cmb_Pname & "')"
If .NoMatch Then
'create new record
.AddNew
!FID_V = FID_V
!Pname = cmb_Pname
id = !ID_myTab
.Update
'Set new record as current record in subform
.FindFirst ("ID_myTab=" & id)
Forms!frm_Main!frm_Sub.SetFocus
Forms!frm_Main.frm_Sub.Bookmark = .Bookmark <<-- Error
Else
'record exists
Forms!frm_Main.frm_Sub.Bookmark = .Bookmark << --Error


End If
rst.close

End

I always get Runtime Error 438: Object does not support property/method
in the above marked lines.
Can anybode help?

Thanks in advance,

Jens
 
V

Van T. Dinh

You cannot assign BookMark from one Recordset to a different Recordset even
if they come from the same DataSource. In your case rst is a different
Recordset from the Subform's Recordset.

Try the RecordsetClone instead of OpenRecordset.

HTH
Van T. Dinh
MVP (Access)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top