This is serta/sorta a form related question.
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
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.