Results 1 to 2 of 2
  1. #1
    toonz is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    3

    Forms Freezes After Record Is Updated


    I have searched all over for this issue and cant find anything on it. It just doesnt make sense at all. I have some VBA that updates a few fields with username, date edited and similar info when a record is updated. I added an extra line to change a different date field when the record is updated, also. This date field already has a date in it, so its basically updating it to the date the record was edited from the original date that is in it. Here is the code

    Code:
    Private Sub Form_AfterUpdate()
    
    If IsNull(Me.user_edit) Then
    Me.user_edit = Environ("Username")
    End If
    If IsNull(Me.user_comp) Then
    Me.user_comp = Environ("Computername")
    End If
    If IsNull(Me.user_date) Then
    Me.user_date = Now()
    End If
    If Not IsNull(Me.date_added) Then
    Me.date_added = Now()
    End If
    
    
    End Sub
    I have this code trigger on the AfterUpdate event of the form. The first 3 variables change fine when a record is updated the first time, but they dont appear to change after the fields have a value in them. The 4th, which already contains data, causes the issue. After experimenting, it seems they probably all would. Basically, when I make an update, and try to go to the next record, it wont. It locks me in to the current record until I hate the ESC key and undo the changes I just made. It seems that all variables need both the IsNull and Not IsNull to make this work properly. Has anyone had an issue like this before?

  2. #2
    toonz is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    3
    UPDATED:

    I updated the code to change even if there is data

    Code:
    Private Sub Form_AfterUpdate()
    
    If IsNull(Me.user_edit) Then
    Me.user_edit = Environ("Username")
    ElseIf Not IsNull(Me.user_edit) Then
    Me.user_edit = Environ("Username")
    End If
    If IsNull(Me.user_comp) Then
    Me.user_comp = Environ("Computername")
    ElseIf Not IsNull(Me.user_comp) Then
    Me.user_comp = Environ("Computername")
    End If
    If IsNull(Me.user_date) Then
    Me.user_date = Now()
    ElseIf Not IsNull(Me.user_date) Then
    Me.user_date = Now()
    End If
    If IsNull(Me.date_added) Then
    Me.date_added = Now()
    ElseIf Not IsNull(Me.date_added) Then
    Me.date_added = Now()
    End If
    
    
    End Sub
    I tried changing a record, click the next button on the navigation panel, and it would go to the next record. However, both date fields DID get updated with the current date/time. I still had to hit ESC to unlock the record and move to the next one, but when I went back and viewed the previous record, the dates were still updated with the new values. It does appear to be updating the fields, but its just not letting me move on to the next record after the update is occuring.

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

Similar Threads

  1. Design view 'freezes' in Access 2010
    By dknowle in forum Access
    Replies: 1
    Last Post: 08-31-2011, 11:05 AM
  2. Replies: 8
    Last Post: 06-22-2011, 10:51 AM
  3. Access Freezes at startup
    By pokerim in forum Access
    Replies: 1
    Last Post: 07-20-2010, 06:28 AM
  4. Access freezes when opening forms
    By thorpef1 in forum Access
    Replies: 0
    Last Post: 01-04-2010, 04:48 PM
  5. Help record navigating in forms
    By edo in forum Forms
    Replies: 0
    Last Post: 08-12-2008, 10:45 AM

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