Avatar of TonyMannella
TonyMannella
Flag for United States of America asked on

MS Access lock editing of a form and its subfroms based on a certain date or a date in the manin form

Hi,

I have constructed an employee time and expense form.  What I would like to do is to disable the user from going back to change the values in a form and its subforms (subform Time, and subform expense).  The main form has a "Week Ending" text box.  I would like to disable editing after 2 days past on the week ending combo box on the main form as well as both subforms.  Can this be done.  See attached screenshot
time-Expenseforms.jpg
Microsoft AccessMicrosoft Applications

Avatar of undefined
Last Comment
TonyMannella

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
mbizup

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
TonyMannella

ASKER
I will try that and let you know how it works.

Thanks,
TonyMannella

ASKER
Quick Question,  How would I put a message box in there to alert the user they can no longer add their time and expense.  Where would I put that code in your code?
TonyMannella

ASKER
Still working on this and will let you know the results
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
mbizup

Hi - I'm sorry I missed your last comment.  


If DateAdd("d", 2, Me.WeekEnding) <= Date then
    me.AllowEdits = False
    Me.[subform Time].Locked = true
    Me.[subform expense].Locked = true
    '*** Add your message box here:
    msgBox "Edits have been disabled"
Else
    me.AllowEdits = true
    Me.[subform Time].Locked = False
    Me.[subform expense].Locked = false
end if


Also, if the code is in the Current Event as I suggested, it will fire when the form opens and also as the user navigates through records (it fires following a record change, once the user is on the record).

If you want this code to fire when the user enters data, you should also add the code to the After UPdate event of your form or the control.
TonyMannella

ASKER
Works Perfectly, Thanks for your help!