Problem with Bookmark, Runtime Error: 3022

parth00

Registered User.
Local time
Today, 12:02
Joined
Sep 23, 2005
Messages
25
I am getting this error and somehow I can’t figure out what is wrong. All I am trying to do is select Employee_ID (Primary Key) from combo box (Employee_ID_Text).
If employee id is found load the employee information.

Error Message:
Runtime Error: 3022”
Changes to you requested to the were not successful because they will create duplicate values in index, primary key or Relationship.

Here is my code….I get above error when VB executes Me.Bookmark = Rs.Bookmark.

Private Sub Employee_ID_Text_AfterUpdate()

Dim Rs As Object
Set Rs = Me.Recordset.Clone

Rs.FindFirst "Employee_Id = " & Str(Me.Employee_ID_Text)

If Rs.NoMatch Then
MsgBox " Record Not found"
Else
Me.Bookmark = Rs.Bookmark
End If

Rs.Close

End Sub

Please comment
 
I am using DAO.

Dim Rstest As DAO.Recordset
I tried printing values for Me.Recordset = ?
and Rstest.Recordset = blank (Null)
 
Try:
Code:
Private Sub Employee_ID_Text_AfterUpdate()

Me.RecordsetClone.FindFirst "[Employee_Id] = '" & Str(Me.Employee_ID_Text) & "'"
If Not Me.RecordsetClone.NoMatch Then
    Me.Bookmark = Me.RecordsetClone.Bookmark
Else
   MsgBox "Record Not found"
End If

End Sub
 
I tried ur code with slight change as I got data type mismatch Error.

Me.RecordsetClone.FindFirst "str([Employee_Id]) = '" & Str(Me.Employee_ID_Text) & "'"
If Not Me.RecordsetClone.NoMatch Then
MsgBox Me.RecordsetClone.Bookmark
Me.Bookmark = Me.RecordsetClone.Bookmark
Else
MsgBox "Record Not found"
End If

I am still getting same Error, Me.RecordsetClone.Bookmark prints ?
 
Change to the next line:
Me.RecordsetClone.FindFirst "[Employee_Id] = " & Me.Employee_ID_Text
and get rid of the 1st MsgBox line.
 
Do *not* bind the Employee_ID_Text ComboBox control to anything. Go to the Data tab of the property sheet for that control and delete the ControlSource. Along with the other changes I gave you it will start to work.
 
You're welcome and thanks for posting back with your success.
 
Just curious...
If I bind text box or combo box control to any control source, I have use that in my code?

Thanks in advance
 

Users who are viewing this thread

Back
Top Bottom