Access form 2105 error

Hi,

I wonder if someone can help me? I have a database which mainly consists of a data entry form for the users to enter details about telephone calls that they receive in a call centre. The form is made up of a number of fields that are dependent on others, however, only two these fields are mandatory. On occasions (and it took me some time to replicate the error that the users were experiencing), the error for 'Complete all mandatory fields' (that I have inserted) is thrown up even though all mandatory fields are completed. When this happens, the user is forced to quit out of the record and to re-enter the data so that it is saved in the backend.

The database structure is set up so that a backend is located on the server and each user has their own copy of the front end. It seems that the error only occurs when users are simultaneously using the database, but the fact that this is happening at all is making the database extremely frustrating for the usesr and myself.

Bleow is the code for the form, hopefully someone may have come across this before and can shed some light on the problem?

Option Compare Database

Private Sub cboDepartment_AfterUpdate()
On Error Resume Next
    Select Case cboDepartment.Value
        Case "Legal"
            cboReasonForError.RowSource = "tblLegalErrorReasons"
        Case "Means"
            cboReasonForError.RowSource = "tblMeansErrorReasons"
        Case "Finance"
            cboReasonForError.RowSource = "tblFinanceErrorReasons"
    End Select
   
    On Error Resume Next
    Select Case cboDepartment.Value
        Case "Legal"
            cboCategoryOfWork.RowSource = "tblLegalWork"
        Case "Means"
            cboCategoryOfWork.RowSource = "tblMeansWork"
        Case "Finance"
            cboCategoryOfWork.RowSource = "tblFinanceWork"
    End Select
End Sub
---------------------------------------------
Private Sub Close_Form_Click()
If Me.Dirty Then
    DoCmd.RunCommand acCmdUndo
    End If

If vbYes = MsgBox("Are you sure you want to exit?", vbQuestion Or vbYesNo, "Exit?") Then
    DoCmd.Quit
  End If
End Sub
---------------------------------------------
Private Sub Form_AfterInsert()

Me.CallID.SetFocus
    MsgBox "Data logged, thank you. Your Call Reference is " & CallID.Text, vbOKOnly, "CST Call Logging"
    DoCmd.GoToRecord , , acNewRec
  
End Sub
---------------------------------------------
Private Sub Form_Current()
On Error Resume Next
   Dim strCallerType As String
   If IsNull(cboReasonForCall.Value) Then
      grpCallerType.Value = Null
   End If
   strCallerType = DLookup("[CallerType]", "tblCallerReasons", "[CallerReason]='" & cboReasonForCall.Value & "'")
   Select Case strCallerType
      Case "Client"
         grpCallerType.Value = 1
      Case "Provider"
         grpCallerType.Value = 2
      Case "Other Party"
         grpCallerType.Value = 3
   End Select
   cboReasonForCall.RowSource = "Select tblCallerReasons.CallerReason " & _
            "FROM tblCallerReasons " & _
            "WHERE tblCallerReasons.CallerType = '" & strCallerType & "' " & _
            "ORDER BY tblCallerReasons.CallerReason;"
End Sub
---------------------------------------------
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
Dim blRet As Boolean
blRet = MouseWheelOFF(False)
End Sub
---------------------------------------------
Private Sub Submit_Click()
On Error GoTo Err_Submit_Click
   
    If Me.Dirty Then
    DoCmd.GoToRecord , , acNewRec
    End If

Exit_Submit_Click:
Exit Sub
      
    If Err.Number = 2105 Then
    Err.Description = MsgBox("Please complete all mandatory fields", vbOKOnly, "CST Call Logging")
    Else
    MsgBox Err.Description
    End If

Resume Exit_Submit_Click
  
End Sub
---------------------------------------------
Private Sub Form_BeforeInsert(Cancel As Integer)
Me.txtUserID = lngUserID
Me!CallID = Nz(DMax("[CallID]", "[tblCallLog]"), 0) + 1

End Sub
---------------------------------------------
Private Sub Cancel_Click()
On Error GoTo Err_Cancel_Click

    If Me.Dirty Then
    DoCmd.RunCommand acCmdUndo
    End If

Exit_Cancel_Click:
    Exit Sub

Err_Cancel_Click:
       
    If Err.Number = 2046 Then
Err.Description = MsgBox("Nothing to undo", vbOKOnly, "CST Call Logging")
Else
MsgBox Err.Description
End If
Resume Exit_Cancel_Click
   
End Sub
---------------------------------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.cboReasonForCall = "Other (Enter details below)" And IsNull(Me.Other) Then
    Me.Other.SetFocus
    Cancel = True
End If
 
If Me.cboReasonForError = "Other (Enter details below)" And IsNull(Me.Other) Then
    Me.Other.SetFocus
    Cancel = True
End If
   
End Sub
---------------------------------------------
Private Sub grpCallerType_AfterUpdate()
    On Error Resume Next
    Dim strCallerType As String
    Select Case grpCallerType.Value
      Case 1
         strCallerType = "Client"
      Case 2
         strCallerType = "Provider"
      Case 3
         strCallerType = "Other Party"
    End Select
    cboReasonForCall.RowSource = "Select tblCallerReasons.CallerReason " & _
            "FROM tblCallerReasons " & _
            "WHERE tblCallerReasons.CallerType = '" & strCallerType & "' " & _
            "ORDER BY tblCallerReasons.CallerReason;"
End Sub

---------------------------------------------
Thanks

Andy

Answer
Answer

Error 2105 is "You can't go to the specified record at this time"

So, you are attempting to use it for having mandatory fields filled in?  That should be validation code in the form's BEFORE UPDATE event.  The problem here is that the user is trying to navigate somewhere they cannot go.  Typically that means like trying to click on a button which you have set to go somewhere but it can't go there.  An example is a navigation button that says to move to the previous record.  But if you are at the first record there is no previous record so it will throw an error 2105. 


Bob Larson, Former Access MVP (2008-2010) http://www.btabdevelopment.com (free Access tools, tutorials, and samples)
-----
Microsoft Access MVP 2008, 2009, 2011
If a post was helpful click the FOUND THIS HELPFUL link

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Answer
Answer

I would add this line

If Me.Dirty Then Me.Dirty = False

which will attempt the save (IF there has been edits or additions in the form) BEFORE you try to advance to a new record.  That may be your prime problem.  You are trying to go to a new record but it can't at that time because it hasn't saved the current one.  So, you would use

 

 

If Me.Dirty Then Me.Dirty = False

DoCmd.GoToRecord , , acNewRec

 

And then if you cancel you MAY have to deal with an ERROR 2501 (You canceled the previous operations) - funny how they have very similar numbers, eh?


Bob Larson, Former Access MVP (2008-2010) http://www.btabdevelopment.com (free Access tools, tutorials, and samples)
-----
Microsoft Access MVP 2008, 2009, 2011
If a post was helpful click the FOUND THIS HELPFUL link

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated January 8, 2024 Views 5,278 Applies to: