PC Review
Forums
Software
Windows XP & Applications
MS Access VBA - 3022 error
Forums
Software
Windows XP & Applications
MS Access VBA - 3022 error
![]() |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Junior Member
|
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 |
|
|
|
|
|
#2 |
|
Senior Member
|
This link might help but I'm not an Access fan so I don't know.
|
|
|
|
|
|
#3 |
|
Junior Member
|
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? |
|
|
|
|
|
#4 | |
|
Senior Member
|
Quote:
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. |
|
|
|
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

