Error 3159 Not a Valid Bookmark

B

Binta

On a a data entry form for "SerialNo", I am checking to
see if the text entered already exists, if it does, the
user is notified and the record is displayed using a
bookmark property (OnExit event) on the Serial number.
The code works fine and displays records for the firt 200
records i.e. chose any serial number from the first 200
record, and anything after 200 i.e. records # 201 gives
me error # 3159 - "Run time Error, Not a valid
bookmark". Can someone explain and is there a different
way of displaying the record. I can post the code too if
needed. Thanks in advance for any help
 
D

Dirk Goldgar

Binta said:
On a a data entry form for "SerialNo", I am checking to
see if the text entered already exists, if it does, the
user is notified and the record is displayed using a
bookmark property (OnExit event) on the Serial number.
The code works fine and displays records for the firt 200
records i.e. chose any serial number from the first 200
record, and anything after 200 i.e. records # 201 gives
me error # 3159 - "Run time Error, Not a valid
bookmark". Can someone explain and is there a different
way of displaying the record. I can post the code too if
needed. Thanks in advance for any help

What version and service level of Access are you using? Do you know
what version of Jet is installed? It seems to me that I've seen a
report of this before, but I don't remember clearly and can only suggest
at the moment that you ensure you have the latest service packs for your
versions of Access and Jet.

Please post the code, although I doubt that's where the problem lies.
 
D

Dirk Goldgar

[...]

By the way, I notice you also posted this question independently in a
different newsgroup. That's called "multiposting", and it's generally
frowned on because others don't know what answers have already been
given, and so they duplicate the effort. Also it's harder for you to
keep track of the various replies, and it's harder for later readers of
the question, who may be looking for the same answer, to learn what they
need.

In most cases a single, well-chosen newsgroup will do. If your question
really is relevant to more than one newsgroup, the approved technique is
to "crosspost" it instead, by listing multiple newsgroups in the To: or
Newsgroups: line of a single message. If you do that, the message and
any replies will appear in all the listed newsgroups automatically,
which is beneficial to all concerned.
 
B

Binta Patel

Here's the Code that I am using. As I said this code
seems to work for the first couple records and then does
not work.

'Using this On BeforeUpdate
Option Compare Database
Dim VarBookmark


Public Function SerialUpdate()

Dim Objrs As ADODB.Recordset
Dim objrs1 As ADODB.Recordset
Dim frm As Form_frmGeneralInfo_New
Dim Serial As ADODB.Field
Dim Serial1 As ADODB.Field
Dim txtSerial As TextBox


Set objrs1 = New ADODB.Recordset
objrs1.Open "tblGeneralInfo", CurrentProject.Connection,
adOpenKeyset, adLockOptimistic

Set Serial1 = objrs1!SerialNo
Set frm = Forms![frmgeneralinfo_new]
Set txtSerial = frm.SerialNo

If objrs1.RecordCount <> 0 Then

objrs1.MoveFirst

Do While Not objrs1.EOF

If (Serial1 = txtSerial.Value) Then

MsgBox "The serial Number you have entered
already exists in the database", vbOKOnly

If Serial1 = txtSerial Then

VarBookmark = objrs1.Bookmark

End If

If Not IsNull(VarBookmark) Then
DoCmd.CancelEvent
SendKeys "{ESC 2}", False
Exit Function
End If
Else
objrs1.MoveNext
End If

Loop

Else
' MsgBox "There are currently no existing records in
the table", vbOKOnly
'do nothing, do not need to compare because there are
no existing records.
End If


End Function
---------------Using this ONExit------------------
Public Function GoToBookMarkRecord()


If Not IsNull(VarBookmark) And Len(VarBookmark) <> 0
Then
DoCmd.CancelEvent
Screen.ActiveForm.Bookmark = Found
VarBookmark = Null
End If

End Function
 
B

Binta

I did not know how to include all the newsgroup and
that's why the multi-posting. I will try to avoid that
in the future. By the way I forgot to mention that the
error occurs in the Public Function GoToBookMarkRecord at
the following line (screen.activeform.bookmark = found).
 
D

Dirk Goldgar

Binta Patel said:
Here's the Code that I am using. As I said this code
seems to work for the first couple records and then does
not work.

'Using this On BeforeUpdate
Option Compare Database
Dim VarBookmark


Public Function SerialUpdate()

Dim Objrs As ADODB.Recordset
Dim objrs1 As ADODB.Recordset
Dim frm As Form_frmGeneralInfo_New
Dim Serial As ADODB.Field
Dim Serial1 As ADODB.Field
Dim txtSerial As TextBox


Set objrs1 = New ADODB.Recordset
objrs1.Open "tblGeneralInfo", CurrentProject.Connection,
adOpenKeyset, adLockOptimistic

Set Serial1 = objrs1!SerialNo
Set frm = Forms![frmgeneralinfo_new]
Set txtSerial = frm.SerialNo

If objrs1.RecordCount <> 0 Then

objrs1.MoveFirst

Do While Not objrs1.EOF

If (Serial1 = txtSerial.Value) Then

MsgBox "The serial Number you have entered
already exists in the database", vbOKOnly

If Serial1 = txtSerial Then

VarBookmark = objrs1.Bookmark

End If

If Not IsNull(VarBookmark) Then
DoCmd.CancelEvent
SendKeys "{ESC 2}", False
Exit Function
End If
Else
objrs1.MoveNext
End If

Loop

Else
' MsgBox "There are currently no existing records in
the table", vbOKOnly
'do nothing, do not need to compare because there are
no existing records.
End If


End Function
---------------Using this ONExit------------------
Public Function GoToBookMarkRecord()


If Not IsNull(VarBookmark) And Len(VarBookmark) <> 0
Then
DoCmd.CancelEvent
Screen.ActiveForm.Bookmark = Found
VarBookmark = Null
End If

End Function

-----Original Message-----
On a a data entry form for "SerialNo", I am checking to
see if the text entered already exists, if it does, the
user is notified and the record is displayed using a
bookmark property (OnExit event) on the Serial number.
The code works fine and displays records for the firt 200
records i.e. chose any serial number from the first 200
record, and anything after 200 i.e. records # 201 gives
me error # 3159 - "Run time Error, Not a valid
bookmark". Can someone explain and is there a different
way of displaying the record. I can post the code too if
needed. Thanks in advance for any help

If that code works at all, there must be something you left out of the
post. There's no definition for "Found", which you are referring to in
GoToBookMarkRecord. And if Found is a function of some sort that
returns the varBookmark, that shouldn't work because the form's
recordset isn't a clone of the recordset from which varBookmark was
taken, and so their bookmarks shouldn't be interchangeable.

I take your intention is to check, in the BeforeUpdate event of
txtSerial on form frmGeneralInfo_New to see if the user's entry already
exists, and if it does, to take him to that record. Is that correct?
Is this code in an MDB or an ADP? If it's in an MDB, the following
would be more efficient:

'----- start of code -----
Private Sub SerialNo_BeforeUpdate(Cancel As Integer)

With Me.RecordsetClone

.FindFirst "SerialNo='" & Me.SerialNo & "'"
' Note: the above line assumes SerialNo is a text field.

If Not .NoMatch Then

MsgBox _
"The serial Number you have entered " & _
" already exists in the database", _
vbOKOnly

Cancel = True
Me.SerialNo.Undo
Me.Undo

Me.Bookmark = .Bookmark

End If

End With

End Sub
'----- end of code -----

It would be done very similarly in an ADP, but I'm more familiar with
the DAO methods.
 

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

Similar Threads


Top