We help IT Professionals succeed at work.

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

297 Views
Last Modified: 2012-06-02
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
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
TonyMannellaBusiness/IT Analyst

Author

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

Thanks,
TonyMannellaBusiness/IT Analyst

Author

Commented:
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?
TonyMannellaBusiness/IT Analyst

Author

Commented:
Still working on this and will let you know the results
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
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.
TonyMannellaBusiness/IT Analyst

Author

Commented:
Works Perfectly, Thanks for your help!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.