Results 1 to 13 of 13
  1. #1
    banpreet is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    117

    Lock Form based on value of combo box


    Hi guys, I have three forms. One form the customer fills out, the status of the form is automatically "Draft" and can not be changed by them. The second form, an approver looks over it and changes the form status from "Draft" to "Pending" from a combo box. Then the third form, there is another approver that signs the form and changes the status from "Pending" to "Final". How do I make it that when the value of the "Pending" and "Final" are chosen from the second and third form, lock the first form so no edits can be made to anything. I have this code that seemed to work at first but doesn't anymore. I put this code in the on load event.

    If Me.Status = "Pending" Or Me.Status = "Final" Then
    Forms!TR_Form.AllowEdits = False

    End If

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    in the table that has the combo choices, add a LOCK field T/F, add this field to the combo box,(2 columns)
    you can hide this column by setting the column widths len=0: 1;0
    when the user picks it, lock the form

    Code:
    sub combo_afterupdate()
      me.locked = combo.column(1)       'in vb code columns start with zero
    end sub

  3. #3
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,480
    Thought I had seen this same post before. https://www.accessforums.net/showthread.php?t=63304

    So what changed to make that code not work anymore?

  4. #4
    banpreet is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    117
    I'm not sure but I added a revision button to the first form for customers field that makes a copy of the form and makes a copy of a record and adds to the table and changes the status from Final to Draft automatically, so the customer can fill out what ever he needs to change after its been approved from the approval process but the form needs change because mistakes happen.

  5. #5
    banpreet is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    117
    ranman, will the lock field lock only the first form, I do not want to lock the second and third form? Thanks

  6. #6
    banpreet is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    117
    what does the T/F mean too? Thanks

  7. #7
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    it only locks the form you are on.
    the T/F is a true/false field in the table where the combo values come from
    [option],[lock]
    pending, true
    final, true
    test, false

    the lock value is tied to the combo option.

  8. #8
    banpreet is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    117
    thanks for that but that wouldn't work for me because the second and third form can't be locked, only the first form no edits should be made but they should have access to buttons.

  9. #9
    banpreet is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    117
    Does anybody else have any other code that would work? Thanks!

  10. #10
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,480
    Seems to me your Approver 1 or 2 (2nd or third forms) should change the status back to Draft if they see errors and need the customer to change something. If you allow the customer to hit a button to then edit the information, you are defeating the propose of locking down the data. Unless I am not understanding what you are saying which is probably true, the key trigger to say if Customer Form1 can be edited is the status. If Draft it can be edited, if not then it cannot be edited. Is that still the case? If so then that code should still work. If on that form the customer can select multiple records, then that code might need to go in the OnCurrent event as you scroll through records, it would check to see the status of each record.

  11. #11
    banpreet is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    117
    Well customer fills out form one in draft status and sends it the approver, the approver changes it to pending to send it to the other approver who it will change it to final. Once in pending it starts the approval process so if a cusomter wants to edit information he can not. After its approved the form, people can view it in report and do their test. But sometimes there will be changes such as an estimate, and then since it was already approved, the customer will get an email that he can revise the form, so the user goes into his form and clicks the revise button making a copy of the form and record and adding 1 to the revision field and changing the status to draft byitself without waiting for the approver, so then the customer will have to go through the same approval process again. Company standards that we need to keep record of revisions, so under the same Test, there can be 1, 2, 3, or 4 revisions for the same test but making new records with the same id.

  12. #12
    banpreet is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    117
    Ok I switch the code on current and I think it worked! Thanks!

  13. #13
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    Other forms are not affected

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

Similar Threads

  1. Lock Value in Combo Box if Non-Blank
    By ErikAE in forum Forms
    Replies: 4
    Last Post: 08-29-2014, 11:23 PM
  2. Replies: 3
    Last Post: 06-18-2014, 10:40 AM
  3. Replies: 1
    Last Post: 10-30-2012, 10:29 AM
  4. Replies: 2
    Last Post: 03-30-2012, 08:26 AM
  5. Replies: 5
    Last Post: 03-12-2012, 02:58 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