B
Binta Patel
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. Thanks in advance for any
help.
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 for the records at the end of the table. Error
Occurs in the function GoToBookMarkRecord
(Screen.activeform.bookmark = varbookmark)
'Using this On BeforeUpdate
Option Compare Database
Dim VarBookmark
Public Function FindSerialDup()
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 = varbookmark
VarBookmark = Null
End If
End Function
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. Thanks in advance for any
help.
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 for the records at the end of the table. Error
Occurs in the function GoToBookMarkRecord
(Screen.activeform.bookmark = varbookmark)
'Using this On BeforeUpdate
Option Compare Database
Dim VarBookmark
Public Function FindSerialDup()
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 = varbookmark
VarBookmark = Null
End If
End Function