Results 1 to 3 of 3
  1. #1
    Jojojo is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    46

    Prevent user from adding subform record if main form has null value

    Is there a way to keep a user from bring able to enter a record in a subform, or giving a message if they try to add a record to a subform, when a certain value/field is null on the main form? The subform consists of a combo box and they do not have to click a cmd button to access the subform. The field in the main form is also a combo box.



    My user has a tendency to skip the main form and enter the info into the subform and then forget to enter the info into the main form all together. I do have required fields built into the table, but because she is closing the form without entering any info into the main form, it doesn't kick in the required fields. She thinks she's entered a record but it's incomplete.

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    simply toggling the visibility is one way, or toggle the lock property of the control or form or toggle the enable property....... kinda sorta just depends on what is the better user interface....

    I tend to toggle visiblity, revealing more and more as the user progresses thru a form so that they stay on the straight & narrow.....

  3. #3
    robsworld78 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    181
    On the subform you don't want the user to access set the "visible" property to no or the "enabled" property to no.

    Then choose which field you want to have the subform become visable or enabled again and in the "AfterUpdate" event on that field add the code

    Me.SubformName.Enabled = True

    or

    Me.SubformName.Visible = True

    Now when the form opens the subform will be disabled or hidden and once a user enters data in the field you chose the subform will reappear or be enabled.

    You should do this to all the fields so a user has to enter data the way you want it entered.

    You can also use the same code anywhere with "False" instead of "true" and that will hide or disable what you tell it to.

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

Similar Threads

  1. Replies: 1
    Last Post: 11-21-2011, 07:58 AM
  2. Replies: 5
    Last Post: 11-11-2011, 11:06 AM
  3. execute code on subform without adding a record
    By markjkubicki in forum Forms
    Replies: 5
    Last Post: 10-13-2011, 12:23 PM
  4. logged user name on main form
    By foxtet in forum Forms
    Replies: 1
    Last Post: 07-30-2011, 03:00 PM
  5. Replies: 1
    Last Post: 10-13-2010, 12: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