Results 1 to 10 of 10
  1. #1
    Bones is offline Novice
    Windows 2K Access 97
    Join Date
    Jan 2011
    Location
    Desert Aire, WA
    Posts
    6

    Post Prohibit change on SOME fields after record is created


    in Access 97, can particular fields (not all) on a form be locked so that the data (once entered) cannot be changed.
    I tried to lock the field, but upon locking you can't even enter NEW data.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I have never used ac97 so this may not apply. In acXP and > there is no way to do this at the table level but you could do it in a Form. Simply put code in the Current Event of the Form to disable (Me.YourControlName.Enable = False) the controls you want when Me.NewRecord is False.

  3. #3
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    if you're interested in the theory of this, and how it relates to online technology that's similar, you might consider using flags or something to identify your records. for instance, a small script that runs once new records are entered to manipulate a boolean field, one way or the other, which indicates the fields permanently locked.

  4. #4
    Bones is offline Novice
    Windows 2K Access 97
    Join Date
    Jan 2011
    Location
    Desert Aire, WA
    Posts
    6
    Private Sub Form_Current()
    If Me.NewRecord = False Then
    Me.Property_Address.Enabled = False
    End Sub

    This code does lock the Property Address field but it is also locked on a new record. Don't I need an ELSE line?

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by Bones View Post
    Private Sub Form_Current()
    If Me.NewRecord = False Then
    Me.Property_Address.Enabled = False
    End Sub

    This code does lock the Property Address field but it is also locked on a new record. Don't I need an ELSE line?
    Yes you do...and an End If.
    Code:
    Private Sub Form_Current()
       If Me.NewRecord = False Then
          Me.Property_Address.Enabled = False
       Else
          Me.Property_Address.Enabled = True
       End If
    End Sub

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    A shorter code would be:
    Code:
    Private Sub Form_Current()
       Me.Property_Address.Enabled = Me.NewRecord 
    End Sub

  7. #7
    Bones is offline Novice
    Windows 2K Access 97
    Join Date
    Jan 2011
    Location
    Desert Aire, WA
    Posts
    6
    Got all 6 of my fields working as planned. One last thing. When I open the form now I am on the first of the 2 fields that are able to be edited as it should be. However, on a new record how do I get the curser to be in the first field again and continue in the correct tab order?

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Since the Event happens when you just get to the new record, the controls will not be enabled yet. As the last line of your event, set the focus to the control you want.
    Me.ControlName.SetFocus
    ...should do it, using *your* ControlName of course.

  9. #9
    Bones is offline Novice
    Windows 2K Access 97
    Join Date
    Jan 2011
    Location
    Desert Aire, WA
    Posts
    6
    That's it!! Thanks again.

    I will mark this post as resolved.

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Excellent! Glad we could help.

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

Similar Threads

  1. Who created new record
    By ducecoop in forum Access
    Replies: 10
    Last Post: 10-28-2010, 02:50 PM
  2. change print preview record source
    By alaric01 in forum Reports
    Replies: 10
    Last Post: 10-07-2010, 09:51 AM
  3. Replies: 1
    Last Post: 09-21-2010, 09:49 AM
  4. Allow change to a field on new record only
    By Grooz13 in forum Forms
    Replies: 4
    Last Post: 08-16-2010, 11:36 AM
  5. Replies: 4
    Last Post: 05-12-2009, 01:50 PM

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