PC Review


Reply
Thread Tools Rate Thread

3159 "Not a valid bookmark" after AddNew & LastModified

 
 
GDW
Guest
Posts: n/a
 
      27th Jan 2006
I receive the 3159 error when the following code hits the line noted by
"->".

Set rs = frmCommand.Recordset

With rs
.AddNew
' .Update
-> frmCommand.Bookmark = .LastModified
End With

I tried inserting "Update" after "AddNew" as I had seen in code
examples elsewhere but the empty record violated constraints and
couldn't be updated. "LastModified" appears to have no value (viewed
in Watch window) after the "AddNew" statement. I thought that
"LastModified" was supposed to represent both new and updated records.

Any ideas?

Thanks,
Gary

 
Reply With Quote
 
 
 
 
GDW
Guest
Posts: n/a
 
      27th Jan 2006
I implemented a workaround for this problem but am still interested in
why this is not working as I would have expected and what other people
do to handle the situation.

My workaround was to the following sub in the frmCommand definition:

Public Sub AddNew()
DoCmd.GoToRecord , , acNewRec
End Sub

Works fine.

Gary

 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      28th Jan 2006
How are frmCommand and rs declared?

If frmCommand is a Form variable, and rs is disambuguiated as from the DAO
library, it should work if you do something like this:

Dim frmCommand As Form
Dim rs As DAO.Recordset
Set frm = Forms("SomeFormNameHere")
Set rs = frmCommand.RecordsetClone
With rs
.AddNew
'Assign field values here.
.Update
frmCommand.Bookmark = .LastModified
End With
Set rs = Nothing
Set frmCommand = Nothing

The RecordsetClone has been around much longer, and seems to be more
reliable.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"GDW" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I implemented a workaround for this problem but am still interested in
> why this is not working as I would have expected and what other people
> do to handle the situation.
>
> My workaround was to the following sub in the frmCommand definition:
>
> Public Sub AddNew()
> DoCmd.GoToRecord , , acNewRec
> End Sub
>
> Works fine.
>
> Gary



 
Reply With Quote
 
GDW
Guest
Posts: n/a
 
      28th Jan 2006
Thanks for the response Allen.

rs is declared as a DAO.RecordSet and frmCommand as a Form. I tried
setting rs to both frmCommand.RecordSet and frmCommand.RecordSetClone.

The problem with your example as I explained in my original email is
that I don't want to assign values to certain fields and the lack of
values in those fields violates constraints and therefore causes an
error upon execution of the Update statement.

I'm guessing that a new record doesn't actually get added to the
RecordSet after AddNew until you perform the Update and that's the
reason that LastModified won't work in my case.

Gary

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
3159 "Not a valid bookmark" after AddNew & LastModified GDW Microsoft Access VBA Modules 3 28th Jan 2006 09:10 AM
3159 "Not a valid bookmark" after AddNew & LastModified GDW Microsoft Access Forms 3 28th Jan 2006 09:10 AM
3159 "Not a valid bookmark" after AddNew & LastModified GDW Microsoft Access Form Coding 3 28th Jan 2006 09:10 AM
Delete rows created when Error 3159 "Not a valid bookmark" encount =?Utf-8?B?SXJpbmUgRi4=?= Microsoft Access Forms 3 21st Jul 2005 07:46 AM
Error 3159 - Not a valid bookmark Binta Microsoft Access Forms 0 14th Jun 2004 05:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:38 PM.