Results 1 to 6 of 6
  1. #1
    bilalo is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    107

    prevent update in a form


    I have a form that contains the following two text boxes: item name and item price, I want to allow the users to insert a new item, but after inserting an item, I want to prevent them from changing its name. I tried every possible vba solution on the item name(before update, after update, ....) but didn't reach the solution. Any help please?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,540
    Quote Originally Posted by bilalo View Post
    I have a form that contains the following two text boxes: item name and item price, I want to allow the users to insert a new item, but after inserting an item, I want to prevent them from changing its name. I tried every possible vba solution on the item name(before update, after update, ....) but didn't reach the solution. Any help please?
    Shame you didn't show us what you've tried.
    Did you try setting the Locked property of the name control in its After Update event and also in the forms On Current event?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    bilalo is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    107
    Quote Originally Posted by Bob Fitz View Post
    Shame you didn't show us what you've tried.
    Did you try setting the Locked property of the name control in its After Update event and also in the forms On Current event?
    If I lock the item name, the users will not be able to insert new records since they can not type the item name

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,540
    Quote Originally Posted by bilalo View Post
    If I lock the item name, the users will not be able to insert new records since they can not type the item name
    They will if you UNlock it in the forms On Current event subject to the control being Null
    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
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,540
    You would need the following code in the forms On Current event and the controls After Update event:
    Code:
        Me.YourName.Locked = Not IsNull(Me.YourName)
    You would need to substitute YourName with the name of your control
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    bilalo is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    107
    Quote Originally Posted by Bob Fitz View Post
    You would need the following code in the forms On Current event and the controls After Update event:
    Code:
        Me.YourName.Locked = Not IsNull(Me.YourName)
    You would need to substitute YourName with the name of your control
    Thank you, it worked perfectly

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

Similar Threads

  1. Replies: 11
    Last Post: 07-04-2018, 03:15 PM
  2. Replies: 4
    Last Post: 08-14-2017, 08:30 AM
  3. Replies: 3
    Last Post: 08-26-2014, 12:52 PM
  4. Replies: 1
    Last Post: 11-21-2011, 07:58 AM
  5. Prevent Saving of Form
    By bburton in forum Access
    Replies: 4
    Last Post: 02-25-2011, 09:26 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