Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Apr 2003
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Run-time Error '2105' (2000)

    <P ID="edit" class=small>(Edited by HansV on 24-Nov-03 21:26. added [tab] tags to preserve indentation and made URL clickable)</P>I am experiencing a very frustrating problem that I hope someone can help me with.

    I have finished this application that I've been working on and it sometimes works, sometimes doesn't. I can't find a rhyme or reason for it, really. My users are getting the run-time '2105' error when they try to save their record, which occurs when the user clicks on the "save" button.

    Here's my code for the "save" button:

    Private Sub cmdSave_Click()
    If IsNull(Me.WEEK_ENDING) = True Then
    MsgBox "Please enter a week-ending date"
    ElseIf Me.lstNames.ListIndex = -1 Then
    MsgBox "Please select an employee"
    Else
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    MsgBox "Your record(s) has(ve) been saved"
    DoCmd.SetWarnings False
    'DoCmd.Close
    'This query appends a new employee's SSN & DEPT to the ACTUAL table so that their hours can be updated
    DoCmd.OpenQuery "qryNewEmployeesActual"
    'Indicates that the new employee's SSN has been added to the ACTUAL table and is no longer a new employee; data can be appended
    DoCmd.OpenQuery "qryNewEmployeeFlag"
    'This query updates the ACTUAL table to reflect the total number of hours worked
    DoCmd.OpenQuery "qryTimeCardUpdate"
    DoCmd.SetWarnings True
    End If
    End Sub

    Here's the code for the "Add" button:

    Private Sub cmdAdd_Click()
    Dim varID_No As Variant
    Dim varDEPT As Variant
    Dim varWEEK_ENDING As Variant
    Dim lngIndex As Long

    'Adds record only if the following conditions are met:
    'The Week Ending date has been entered
    If IsNull(Me.WEEK_ENDING) = True Then
    MsgBox "Please enter a week-ending date"
    'A name must be selected
    ElseIf Me.lstNames.ListIndex = -1 Then
    MsgBox "Please select an employee"
    'Sets the defaults to whatever the previous record was.
    lngIndex = Me.lstNames.ListIndex
    varDEPT = Me.DEPT
    varWEEK_ENDING = Me.txtWeekEnding
    'Advance to the next record -- see http://support.microsoft.com/default.aspx?...kb;en-us;128195
    'DoCmd.GoToRecord , , acNewRec
    'Sets focus to the next record
    If lngIndex < Me.lstNames.ListCount - 1 Then
    Me.lstNames = Me.lstNames.ItemData(lngIndex + 1)
    End If
    'Sets next variables
    Me.DEPT = varDEPT
    Me.txtWeekEnding = varWEEK_ENDING
    'Sets the focus on the text box
    Me.txtHours.SetFocus
    End If
    End Sub

    Here's what Microsoft has to say about the run-time '2105' error:
    http://support.microsoft.com/default.aspx?...kb;en-us;128195

    They're talking about (1) the BeforeUpdate procedure, which I'm not using here and (2) my Save button code does not contain the acNewRecord command -- the "Add" button does, which the user clicks before to jump to the next record.

    Any advice/thoughts?

    Thanks,
    Kindra

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Run-time Error '2105' (2000)

    You should try to find out on which line of the code the error occurs. Since you don't have error handling, the user should get a choice End / Debug / Help, selecting Debug will highlight the offending line.

  3. #3
    2 Star Lounger
    Join Date
    Apr 2003
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run-time Error '2105' (2000)

    It highlights on the:

    DoCmd.GoToRecord , , acNewRec

    event. Which is weird because it's in the "cmdAdd" part, but the Add button isn't the one being clicked when the users get this error.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Run-time Error '2105' (2000)

    Are you sure yu haven't mixed up the the buttons, so that cmdAdd has caption "Save" and cmdSave has caption "Add"? It doesn't make sense for a line in cmdAdd_Click to be highlighted if the user clicks cmdSave.

  5. #5
    2 Star Lounger
    Join Date
    Apr 2003
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run-time Error '2105' (2000)

    I know, this is why I am so perplexed!!!

    Yes, I am positive that the buttons are correct. I have watched 2 people do it (and have done it myself) and it seems to be working right now. It seems to be a very tempermental application though!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •