Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2019
    Posts
    8

    Angry Lock Field on form unless new record

    I have tried a few different "on event" codes and cannot get my form to work the way I need it to. I have a few things going on but to simplify it I'm in need of an easy fix.



    I have a main form "sfrm_customers" that has six fields displayed from the customer table I created (tbl_customers). I created a combo bx for customer name and an "add new record" button to my form.

    CustomerID - Primary
    CustomerName - no duplicates
    AssignedSls
    AssignedPrm
    AssignedEva
    AssignedPrc

    The "assigned" fields are assigned leads for these clients in different departments.

    My goal is to lock the customername field unless it's a new record being added. I do not want anyone modifying a customer name once the record has been created. CustomerID is locked at the base of the table by default since it's on autonumber and primary key.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    In the current event of the form, test for a new record:

    If Me.NewRecord Then

    and set the locked property of the textbox to True or False as appropriate.

    I suspect you have a design problem. What do the assigned fields represent?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    Nov 2019
    Posts
    8
    Thanks. This is very helpful! I got it to work! Now I'm having issues with a new form i created. I have a combo box called cbocustomerlist on main form and a datsheet query driven subform called sfrm_quotedetails that's linked. My goal is to have the subform display results but locked until a value is selected in the combo box. once the value is selected they should be allowed to add new record. I can't seem to get this to work. Allow additions is on no on my subform for deafult. My subform is not editable either for existing records and deletions are a no. The whole purpose of this form is to create a new quote but allow them to enter details into it as well from another table.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You can change those properties from the after update event of the combo. Along the lines of:

    Code:
    If Len(Me.ComboName & vbNullString) > 0 Then
      Me.sfrm_quotedetails.Form.AllowAdditions = True
      ...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Join Date
    Nov 2019
    Posts
    8
    Quote Originally Posted by pbaldy View Post
    You can change those properties from the after update event of the combo. Along the lines of:

    Code:
    If Len(Me.ComboName & vbNullString) > 0 Then
      Me.sfrm_quotedetails.Form.AllowAdditions = True
      ...
    Thank you! I'm a newbie still and just trying to create a quote data entry form for my team here at work. I have always done built tables and created queries for existing data. I have never had to build a form. This is more complex than I thought. Do you have any suggestions for beginners? My biggest challenge, where I"m getting confused, is how to have one form or command object reference one another and talk to one another or be dependent on the other. Some basic learning material would help.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. How to lock field on form
    By Daisy509th in forum Forms
    Replies: 3
    Last Post: 03-15-2018, 09:16 AM
  2. Lock form to the record being edited
    By joecamel9166 in forum Forms
    Replies: 3
    Last Post: 03-24-2016, 03:09 PM
  3. Lock/unlock current record in continous form ?
    By Lukael in forum Programming
    Replies: 5
    Last Post: 02-17-2016, 01:04 PM
  4. Lock a field on a form
    By pbouk in forum Forms
    Replies: 3
    Last Post: 03-25-2013, 10:45 PM
  5. Replies: 2
    Last Post: 06-25-2012, 08:30 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