Results 1 to 5 of 5
  1. #1
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85

    Lock field after auto date fill

    I have the following code:

    Private Sub Doc_Purged_By_Exit(Cancel As Integer)

    If Doc_Purged_By > "0" And Doc_Purged_Date = "" Then
    Me.Doc_Purged_Date = Date
    Me.Purge_Time = Time
    Refresh
    Else
    Me.Doc_Purged_Date = ""
    Me.Purge_Time = ""
    End If


    End Sub



    What happens is when the "Doc_Purged_By" field is populated on a record in the subform and you exit this field the above code runs, populating a date in the "Doc_Purged_Date" field on the same record. The issue I am having is when I go in to another record on the subform to update it the previous records date is updated to the current date instead of keeping the previous date. I think I need to lock or disable or both the date field after the update. Can you help me accomplish this?
    Thanks.

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    lock/disable only affects the user interface in regard to manually typed entries. anything entered via code would need to be resolved via code.

  3. #3
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    Quote Originally Posted by NTC View Post
    lock/disable only affects the user interface in regard to manually typed entries. anything entered via code would need to be resolved via code.
    So are you willing to help me out with the code?

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    You could try something like:
    Code:
    If Doc_Purged_By > "0" And Doc_Purged_Date = "" Then
      If IsNull(Me.Doc_Purged_Date) Then
        Me.Doc_Purged_Date = Date
      End If
      Me.Purge_Time = Time
      Refresh
    Else
      Me.Doc_Purged_Date = ""
      Me.Purge_Time = ""
    End If
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    Quote Originally Posted by Bob Fitz View Post
    You could try something like:
    Code:
    If Doc_Purged_By > "0" And Doc_Purged_Date = "" Then
     If IsNull(Me.Doc_Purged_Date) Then
        Me.Doc_Purged_Date = Date
     End If
     Me.Purge_Time = Time
     Refresh
    Else
     Me.Doc_Purged_Date = ""
     Me.Purge_Time = ""
    End If
    Thanks for your help. I changed the code to:
    Private Sub Doc_Purged_By_Exit(Cancel As Integer)


    If IsNull(Me.Doc_Purged_Date) And Doc_Purged_By > "0" Then
    Me.Doc_Purged_Date = Date
    End If
    Me.Purge_Time = Time
    Refresh


    End Sub

    and it works.

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

Similar Threads

  1. Auto-fill one field from another table
    By tasoper in forum Access
    Replies: 3
    Last Post: 06-13-2014, 07:17 AM
  2. Replies: 10
    Last Post: 11-21-2011, 02:56 AM
  3. Auto fill a due date column in a query
    By Dexter in forum Queries
    Replies: 7
    Last Post: 02-23-2011, 07:00 AM
  4. Replies: 5
    Last Post: 01-20-2011, 11:36 PM
  5. Auto-fill field not saving to table
    By aaid in forum Forms
    Replies: 1
    Last Post: 12-18-2009, 05:34 PM

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