Results 1 to 6 of 6
  1. #1
    trevor is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2018
    Location
    Orlando, FL, USA
    Posts
    10

    Question AfterUpdate() - Run-time error '2115', but the VBA code seems to work and updates my text box.

    Hi everyone,



    In my project I am trying to add and text box that will populate with the current date when a status for the customer is selected from the combo box.

    I have changed my Status_Combo_AfterUpdate() property, after changing the status I crevice the following error message:

    Click image for larger version. 

Name:	VBADebug2115.PNG 
Views:	21 
Size:	6.6 KB 
ID:	36307

    However, it does update the text box with the short date as intended and it writes this data to the back end database with no issues. Can anyone provide some insight to what I'm missing on this? VBA code is below.


    Code:
    Option Compare Database
    'Copy Phone 1 Value to Clipboard
    Private Sub CmdCopyPhone1_Click()
    If IsNull(Phone1) Then
        MsgBox "No Value to Copy"
    Else
        Me.Phone1.SetFocus
        DoCmd.RunCommand acCmdCopy
    End If
    End Sub
    
    
    'Copy Phone 2 Value to Clipboard
    Private Sub cmdCopyPhone2_Click()
    If IsNull(Phone2) Then
        MsgBox "No Value to Copy"
    Else
        Me.Phone2.SetFocus
        DoCmd.RunCommand acCmdCopy
    End If
    End Sub
    
    
    Private Sub Command728_Click()
    '[Recalls - eResponsibility Matching VIN Query subform].Requery
    End Sub
    
    
    'Store VIN number in a TempVar and requery the search for matching vin numbers.
    Private Sub Form_Current()
    TempVars!TempVin = Me.VIN.Value
    [Recalls - eResponsibility Matching VIN Query subform].Requery
    End Sub
    
    
    'Store VIN number in a TempVar and requery the search for matching vin numbers.
    Private Sub ID_Change()
    TempVars!TempVin = Me.VIN.Value
    [Recalls - eResponsibility Matching VIN Query subform].Requery
    End Sub
    
    
    'Copies saftey recall description to the clipboard.
    Private Sub RecallCopyCMD_Click()
    If IsNull(SafteyRecallTxt) Then
        MsgBox "No Value to Copy"
    Else
        Me.SafteyRecallTxt.SetFocus
        DoCmd.RunCommand acCmdCopy
    End If
    End Sub
    
    
    Private Sub Status_Combo_AfterUpdate()
    
    
    'Add last modified date to database.
    Me.LastModifiedTxt.SetFocus
    Me.LastModifiedTxt.Text = Format(Now(), "MM/DD/YYYY")
    
    
    '-------------------------------------------------------------
    
    
    'Check is user has completed all tasks for this assignment.
    
    
    With Recordset
      If .AbsolutePosition = .RecordCount - 1 Then
    'User has no more records assigned.
            MsgBox ("You have no more open calls. :)")
            DoCmd.Close
    'User has more task to complete.
      Else
            DoCmd.GoToRecord , , acNext
      End If
    End With
    End Sub
    
    
    
    
    'Copy VIN To Clipboard
    Private Sub cmdCopyVIN_Click()
    If IsNull(VIN) Then
        MsgBox "No Value to Copy"
    Else
        Me.VIN.SetFocus
        DoCmd.RunCommand acCmdCopy
    End If
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Didn't post the BeforeUpdate or ValidationRule code.

    Set breakpoint, step debug. What line throws that error?

    Why are you using DoCmd.Close? What exactly do you want to close?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    trevor is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Location
    Orlando, FL, USA
    Posts
    10
    Not in the office so I don't have access till the morning.

    This line causes the error if you go step by step.

    Code:
     Private Sub Status_Combo_AfterUpdate()
    
    
    
    
    'Add last modified date to database.
    Me.LastModifiedTxt.SetFocus
    Me.LastModifiedTxt.Text = Format(Now(), "MM/DD/YYYY")
    There is no BeforeUpdate or ValidationCode in this form. That's the odd part.

    Do.Cmd.Close closes the current window ofter a user finishes all their task and takes them back to the main screen.

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Change to
    Me.LastModifiedTxt = Format(Now(), "MM/DD/YYYY")

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Good catch Dave, I should have seen that when I first read posted code.

    Value is the property you want to set and it is the default for data controls.

    I think it would be Text in VB.net.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Me.LastModifiedTxt.Text = Format(Now(), "MM/DD/YYYY") would not be a problem on an unbound form so I'm not sure it's the problem here. However, by not using the Text property, you can avoid having to set the focus to the control.

    I question why format Now when you can just write the date? Since the error message can also apply to violation of a validation rule, is it possible that the field isn't date/time or the result of the expression violates such a rule?

    I also wonder if the control given the focus is part of the same record (which would be in edit mode due to the combo update), or if there's a form/subform setup involved here. The violation could also be related to a subform record problem.

    EDIT
    text property may or may not be a vb.net property, but it is certainly a vba property. In a bound control, .Value is the last saved data, .Text is the current data displayed in the control. If you leave the control, the .Value property becomes what the .Text was.
    Last edited by Micron; 11-23-2018 at 11:21 PM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 05-10-2018, 07:48 AM
  2. My code throws error 424. How do i work around this?
    By ThornofSouls in forum Programming
    Replies: 2
    Last Post: 09-11-2015, 06:30 AM
  3. Unbound text box real time updates
    By DB2010MN26 in forum Forms
    Replies: 14
    Last Post: 12-11-2011, 02:23 PM
  4. Replies: 2
    Last Post: 09-08-2011, 11:14 AM
  5. AfterUpdate event code error?
    By agripa86 in forum Programming
    Replies: 3
    Last Post: 08-12-2011, 09:12 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums