Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    billgyrotech1 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    May 2019
    Posts
    179

    Smile Locking Certain Fields on Form When Printing Report

    Hello,

    This has to do with the AFRs Form.

    I would like to lock (read only) certain fields on the AFRs form after the Clerk enters the initial information. I tried to use a button to run code to lock these fields but when reopening the AFRs Form those fields aren't locked.

    It would be better to lock those fields when printing the report Tear Down automatically. These fields need to remain unchanged for the future of this particular record (referenced by the AFR Number). Unless of course the initial information needs to change due to input error.

    I want these fields to be locked:



    Me!AFRNumber.Locked = True
    Me!SONumber.Locked = True
    Me!ReceivedDate.Locked = True
    Me!Status.Locked = True
    Me!Warranty.Locked = True
    Me!ProperID.Locked = True
    Me!HiddenDamage.Locked = True
    Me!CheckedADs.Locked = True
    Me!CheckedSBs.Locked = True
    Me!Clerk.Locked = True
    Me!Customer.Locked = True
    Me!Description.Locked = True
    Me!PartNumber.Locked = True
    Me!SerialNumber.Locked = True
    Me!CustomerComplaint.Locked = True
    Me!PreliminaryInspection.Locked = True

    Thank you very much I really do appreciate the help.

  2. #2
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    I would use the Me.NewRecord property in the On Current event something like

    Code:
    Dim bLock as Boolean
    
    bLock = Not Me.NewRecord
    
    Me.AFRNumber.Locked = bLock
    Me.SONumber.Locked = bLock 
    
    etc. etc.
    
    
    This way your controls are editable while it's a new record, but not once it's saved.
    I would have a button on the form to "Allow Edits" which unlocked these controls if an edit was needed.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    billgyrotech1 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    May 2019
    Posts
    179
    Thank you for the reply. I am very new to coding and not really sure what you mean sorry.

    I will try however.

  4. #4
    billgyrotech1 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    May 2019
    Posts
    179
    Thank you for the reply. I am very new to coding and not really sure what you mean sorry.

    I will try however.

  5. #5
    billgyrotech1 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    May 2019
    Posts
    179
    These fields need to be locked also for existing records which I should have mentioned.

    I have thought of having different Front Ends. One version is open so the Clerk can edit fields. Another version would be for the Technicians that would have the fields locked for those mentioned no matter what AFR Number is entered.

    Any thoughts?

  6. #6
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    To answer your questions in order;
    These fields need to be locked also for existing records which I should have mentioned.
    The code I posted would accommodate this. The controls will only normally be unlocked on a New record.

    No need for two versions. You can have the allow edits button, and enable or disable it based on who is using the database.

    You can also simplify the code by using the tag property. I'll try and adjust your sample to demonstrate.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    billgyrotech1 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    May 2019
    Posts
    179
    Don't worry I will figure something out. Most likely I deserve this for being very disrespectful to others on here.

    Bye

  8. #8
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    Well that is your choice.
    I've made a simple addition to your form using the tag property so that you can easily modify which controls are locked / not locked based on the new record.

    See if it makes sense as it's a common way of disabling edits on existing records.
    AFR System 10.8.zip
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  9. #9
    billgyrotech1 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    May 2019
    Posts
    179
    Disregard this reply
    Last edited by billgyrotech1; 06-06-2019 at 04:15 AM.

  10. #10
    billgyrotech1 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    May 2019
    Posts
    179
    Could this method have different levels of disabling edits on existing records. What I mean is this works for the initial entry by the Clerk. How can the whole record be locked ? Could it be launched by the change in the Status field or perhaps a Yes/No field with a checkmark?

    There will be many open AFRs and throughout the day some are finished but should stay open for the Technician to make a change in case they made a mistake. In this scenario I will be closing the AFRs at the end of the day so perhaps a macro to pull up any AFRs with Finished Dates that are still open so at that time I can check them off to close them.

    I hope this makes any sense and thank you for the help.

  11. #11
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    As well as the NewREcord check you could also check the Close date as part of the criteria, if its today then don't lock.
    On of the secrets with this type of mainly linear processing is to record and use things you need as the flags for status checking. Rather than introducing another field for one purpose simply use your close date.

    So your field locking criteria would be something like this , so if it was finished today or it's a new record don't lock it.

    Code:
    Private Sub Form_Current()
        
        Dim bLock As Boolean
        Dim ctl As Control
        
        If Me.NewRecord Or (Me.FinishedDate = Date()) Then      ' You could do this all on one line but this explains the principle much better
            bLock = False
        Else
            bLock = True
        End If
    
    
        For Each ctl In Me.Controls
            If ctl.Tag = "UnLockNew" Then   'The Tag property is in the "Other" tab of all controls.
                ctl.Locked = bLock
           
            End If
        Next ctl
            
    End Sub
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  12. #12
    billgyrotech1 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    May 2019
    Posts
    179
    Duplicate of another reply sorry.
    Last edited by billgyrotech1; 06-06-2019 at 08:39 AM. Reason: Duplicate

  13. #13
    billgyrotech1 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    May 2019
    Posts
    179
    Thank you I tried this and started a new AFR 99999. I clicked on the 'Lock' button and the fields for the Clerk locked. I commented out the field Status in the code so that could be used to trigger the record to be Closed.

    I did that and selected 'Closed' in the Status field. Shouldn't that make the entire record read only including the parts for that AFR? Perhaps a way for the Administrator to pull up all AFRs that have Finished Dates but are still Open. That way they could be selected to be in Closed Status.

  14. #14
    billgyrotech1 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    May 2019
    Posts
    179
    Would this work or something like it?

    Code:
    Private Sub Form_Current()
    If Me.Status = Open Then
     
    Me.AllowDeletions = False
    Me.AFRsParts.Form.AllowAdditions = False
    Me.AFRsParts.Form.AllowDeletions = False
    Me.AllowEdits = False
    Me.AFRsParts.Form.AllowEdits = False
     
    Else
     
    Me.AllowDeletions = True
    Me.AFRsParts.Form.AllowAdditions = True
    Me.AFRsParts.Form.AllowDeletions = True
    Me.AllowEdits = True
    Me.AFRsParts.Form.AllowEdits = True
     
    End If
    End Sub

  15. #15
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    Yes if the Status is what determines the "editable" flag effectively, you can simplify that to

    Code:
    Private Sub Form_Current()
    
    If Me.Status = "Open" Then
     
       Me.AllowEdits = False
       Me.AFRsParts.Form.AllowEdits = False
     
    Else
       Me.AllowEdits = True
       Me.AFRsParts.Form.AllowEdits = True
     
    End If
    End Sub
    As disabling edits I believe would stop any of the other actions.

    Along with others I personally would have a more intuitive way of searching for records than Ctrl+F.
    You can build some sophisticated search functionality into forms.
    Maybe a button to filter to only open jobs, and a drop down combo for those AFR's that match the filter status ?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 06-19-2017, 11:06 AM
  2. Locking Fields on a Table on a Form
    By Loup in forum Access
    Replies: 18
    Last Post: 05-02-2017, 06:47 AM
  3. NOT printing certain fields in a report
    By papabill in forum Queries
    Replies: 2
    Last Post: 02-22-2015, 06:42 PM
  4. Replies: 3
    Last Post: 12-29-2014, 01:04 PM
  5. Locking fields in Access form
    By sk88 in forum Access
    Replies: 10
    Last Post: 06-04-2012, 01:40 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