Full Version: Need a popup for a 2448 Error
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
Aquadevel
Hi My 'Utter Friends,

This is serta/sorta a form related question. smile.gif

I'm using the following calender code to give the end user the option to clicking on the date select popup
instead of typing it in, which works great by the way.

The issue I just found is when 2 people try and edit the same record using the calendar. Access gives the
message 'Error 2448, you cannot change the object......'.

I would like to have a custom message popup, telling the user 'Another user is trying to update the same record, etc.'.
And for the life of me I can't seem to remember how to watch for the error's.

The code is:

CODE
Private Sub btnDateChosen_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error GoTo btnDateChosen_MouseDown_Error
Dim DayValue As Integer
Dim TheDate As Variant
DayValue = (1 + Me![DayZero] + (X \ (Me![1].Width) + (7 * (Y \ (Me![1].Height)))))
If ((DayValue > 0) And (DayValue <= Me![Days])) Then
    TheDate = DateValue(Str$(DayValue) & Format$([CalendarMonth], "/mmm/yyyy"))
    If Me.Parent.lblTime.Caption = "NO TIME" Then
        TheDate = TheDate & " " & Me.Parent.cboHrs & ":" & Me.Parent.cboMins
    End If
    If (OArgs & "" = "") Then
        Forms(sFrm)(sCtl) = TheDate 'returns the date with the control format specified
    Else
          
'<<<<<<  Access error on the following line............. >>>>>>>    
  
        Forms(sFrm)(OArgs).Form(sCtl) = TheDate 'returns the date with the control format specified
    
    
    End If
    DoCmd.Close A_FORM, "frmCalendar"
End If
btnDateChosen_MouseDown_Exit:
    On Error Resume Next
    DoCmd.SetWarnings True
    DoCmd.Hourglass False
    Exit Sub
btnDateChosen_MouseDown_Error:
    MsgBox "An Error Has Occurred..." & Chr$(13) & Chr$(10) & "[" & Str$(Err) & "] " & Error$, 16, "btnDateChosen_MouseDown"
    Resume btnDateChosen_MouseDown_Exit
End Sub



As always, thanks in advance for any insight. smile.gif

strive4peace
Hi Aqua,

if err.number = 2448 then
Aquadevel
Crystal,

It just those 'little' things that I forget. :(

Many Thanks!!!

sad.gif
Aquadevel
Crystal,

Isn't error code - -2147217887 correct of 'record locked' in A2K3?

I can't seem to get it's popping up.

I did get the calendar issue fixed tho'. sad.gif
strive4peace
hi Aqua,

here is the standard code I use when I put in an error handler:

CODE
'~~~~~~~~~ Error handler code ~~~~~~~~~
  
   'set up Error Handler -- put at top of procedure
   On Error GoTo Proc_Err

   'statements

   'then, at the bottom of the procedure:

Proc_Exit:
   On Error Resume Next
   'close and release object variables
   Exit Sub/Function
  
Proc_Err:
   SELECT CASE err.number
   'put in case statements for specific error numbers you want to handle
   case 998, 999
       'statements
   case 9998, 9999
       'statements
   END Select

   'if you are here, the specific number was not handled

   MsgBox Err.Description, , _
        "ERROR " & Err.Number _
        & "   ProcedureName"

   'press F8 to step through code and debug
   'remove next line after debugged
   If IsAdmin() then Stop: Resume

   Resume Proc_Exit

End Sub/Function


where
ProcedureName is the name of your procedure so you can identify what code the problem is in when you see the error

While I am developing, I like to make the error handler go to the line that caused the problem so I can see where it is. Stop will stop the code and Resume goes back to the offending line. When code Stops, press F8 to execute one statement at a time.

The line labels do not matter (Proc_Exit:, Proc_Err:), I like to use the same ones all the time -- they only have to be unique within a procedure.


then, in a general (standard) module:

CODE
'~~~~~~~~~~~~~~~~~~~~~~ IsAdmin
Function IsAdmin() As Boolean
   'while developing, set to True
   'for distribution, set to False
   'unless you have savvy users and instruct them what to do if they pop into code <smile>
   IsAdmin = True
End Function
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.