PC Review Forums Software Windows XP & Applications MS Access VBA - 3022 error

Reply
 
Thread Tools Rate Thread
Old 25-04-2008, 11:20 AM   #1
Rockin_R63
Junior Member
 
Rockin_R63's Avatar
 
Join Date: Apr 2008
Posts: 3
Trader Rating: (0)
Exclamation MS Access VBA - 3022 error

I am writing an Access application for work. I have the whole thing up and running just lovely *except* trying to do customised error trapping. Please could someone evaluate the code below and give me a clue where i'm going wrong?
I am trying to trap error 3022 (that record already exists), so that if a user tries to input a record that would duplicate values, then they are given a msgbox asking if they want to edit the existing record, if yes, then go to the record; if not, clear the form and go to a new record. the 'no' part of this error trap i understand and have not yet coded. The problem i'm having is in the recordset.findfirst section.... The code falls at the line coloured red (it gives a 3022 error...)
Code is below

Private Sub Command11_Click()
On Error GoTo ErrorHandler

Me.Refresh

CleanUpAndExit:
Exit Sub

ErrorHandler:
Select Case Err.Number
Case 3022
Call MsgBox("That record already exists." & vbCrLf & _
"Do you want to edit the record?", vbYesNo)
If VbMsgBoxResult.vbYes Then
Dim rst As DAO.Recordset
Dim strFull As String
strFull = "[nameFull] = '" & Me.nameFull.Value & "'"
Set rst = Me.RecordsetClone
Me.Undo
rst.FindFirst (strFull)
Me.Bookmark = rst.Bookmark
Else
MsgBox ("boo")
End If
End Select
Call MsgBox("Error Code: " & Err.Number & ", " & Err.Description)
Resume CleanUpAndExit

End Sub
Rockin_R63 is offline   Reply With Quote
Old 25-04-2008, 12:20 PM   #2
SlimJim
Senior Member
 
Join Date: Feb 2006
Posts: 130
Trader Rating: (0)
Default

This link might help but I'm not an Access fan so I don't know.
SlimJim is offline   Reply With Quote
Old 25-04-2008, 04:27 PM   #3
Rockin_R63
Junior Member
 
Rockin_R63's Avatar
 
Join Date: Apr 2008
Posts: 3
Trader Rating: (0)
Default

Magic SlimJim.


It hasn't solved the whole problem, but it HAS solved the immediate one.
BTW your login name anything to do with the Stray Cats' Slim Jim Phantom?
Rockin_R63 is offline   Reply With Quote
Old 25-04-2008, 05:16 PM   #4
SlimJim
Senior Member
 
Join Date: Feb 2006
Posts: 130
Trader Rating: (0)
Default

Quote:
Originally Posted by Rockin_R63

It hasn't solved the whole problem, but it HAS solved the immediate one.
BTW your login name anything to do with the Stray Cats' Slim Jim Phantom?


It's a blast from the past. SlimJim (or drainpipe) was the nickname of the jeans we wore in the fifties when I really was slim. My nickname then was Fats (mainly because I was a Fats Domino fan). It now works in reverse.
SlimJim is offline   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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off