From: gsnidow via AccessMonster.com on
Ok, I have simplified things a bit. I took out all of the SQL and insert
stuff, so now the only thing the sub is doing is showing the current rs.
bookmark then doing a requery on the sub form, then attempting to apply the
bookmark. I have added an INT primary key to the table, thinking my long
VARCHAR key was the problem. Still the same thing. Below is the new
simplified code, and, again, the bookmark works some of the time, but not
others. In all cases, the rs.bookmark shown by the msgbox is the same as the
ID field of the table. Thank you for any advice.


Private Sub cmdAddNote_Click()
On Error GoTo Err_cmdAddNote_Click

'There is a button on the sub form that opens up
'the popup form "frmAddNote", which has only one text box
'and one button, cmdAddNote which, when cliked, fires
'this sub.
Dim rs As New ADODB.Recordset

'declare variable for subform to simplify typing
Dim frm As Form
Set frm = Forms!frmZMMR41_ZZMB52_Main!Child1.Form

Dim ID As Long 'this is the new primary key of the record set

'Get the key prior to inserting the note
ID = frm!ID.Value

Set rs = frm.RecordsetClone
rs.MoveFirst
rs.Find "id = " & ID
'Display the rs.bookmark. It should always be equal
'to the value displayed in the ID text box, which is
'the new primary key of the table. In all cases, the
'bookmark displayed is correct.
MsgBox (rs.Bookmark)
frm.Requery
frm.Bookmark = rs.Bookmark

rs.Close

DoCmd.Close acForm, "frmAddNote"

Exit_cmdAddNote_Click:
Exit Sub

Err_cmdAddNote_Click:
MsgBox Err.Description
Resume Exit_cmdAddNote_Click
End Sub

Jeanette Cunningham wrote:
>I probably should have noted I am using Access 2003 .
>ADP with SQL Server 2000.
>
>Yes, a good idea to mention it. I have to bow out here.
>I don't have experience with Access 2003 .
>ADP with SQL Server 2000.
>
>Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
>
>> Jeanette,
>> I have read several posts indicating the rs.FindFirst method, but it
>[quoted text clipped - 34 lines]
>>>>
>>>> Greg

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201003/1