Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old Today, 06:17 AM   #16
ridders
Newbee moderator
Gold Supporter
 
ridders's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 5,532
Thanks: 79
Thanked 1,368 Times in 1,277 Posts
ridders is a jewel in the rough ridders is a jewel in the rough ridders is a jewel in the rough ridders is a jewel in the rough
Re: Lock editing based on date and time elapsed

Now why didn't I think of that....?

__________________
Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left and leave a comment.

New example databases:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


-------------------------
nil illegitimi carborundum est
ridders is offline   Reply With Quote
Old Today, 07:16 AM   #17
josephbupe
Newly Registered User
 
Join Date: Jan 2008
Posts: 224
Thanks: 32
Thanked 1 Time in 1 Post
josephbupe is on a distinguished road
Thumbs up Re: Lock editing based on date and time elapsed

Quote:
Originally Posted by ridders View Post
OK - I think its now working

Getting the code to fire reliably was as I expected quite tricky.
Please can you check it works correctly for you



Wow! It works as expected. Thank you so much.



Code:
Private Sub Form_Current()
Dim dteDate As Date
    'the next 2 line will give the datetime 20 minutes ago as 1/72 day = 0.138889
    dteDate = CDate(CDbl(Now()) - 0.0138889)
  
                Me.AllowEdits = True
                Me.CommandCalendar1.Visible = True
                Me.CommandCalendar2.Visible = True
                Me.ComboCategory.Enabled = True
                Me.ComboCountry.Enabled = True
                Me.ComboCrime.Enabled = True
                Me.frmEvents_Coordinators!ComboCoordinator.Enabled = True
                Me.frmEvents_Coordinators!CommandRemove.Enabled = True
                Me.subfrmParticipants!ComboParticipants.Enabled = True
                Me.subfrmParticipants!CommandRemove.Enabled = True
                Me.frmEvents_ResPersons!ComboResPerson.Enabled = True
                Me.frmEvents_ResPersons!ComboRole.Enabled = True
                Me.frmEvents_ResPersons!CommandRemove.Enabled = True
'data
    If DLookup("[data]", "tblCoordinators", "[userID]='" & Forms!frmEvents_Menus!txtUserID.Value & "'") = -1 Then
        If Not IsNull(Me.txtEvent_ID) And Me.txtDateEventAdded < dteDate Then
                Me.AllowEdits = False
                Me.CommandCalendar1.Visible = False
                Me.CommandCalendar2.Visible = False
                Me.ComboCategory.Enabled = False
                Me.ComboCountry.Enabled = False
                Me.ComboCrime.Enabled = False
                Me.frmEvents_Coordinators!ComboCoordinator.Enabled = False
                Me.frmEvents_Coordinators!CommandRemove.Enabled = False
                Me.subfrmParticipants!ComboParticipants.Enabled = False
                Me.subfrmParticipants!CommandRemove.Enabled = False
                Me.frmEvents_ResPersons!ComboResPerson.Enabled = False
                Me.frmEvents_ResPersons!ComboRole.Enabled = False
                Me.frmEvents_ResPersons!CommandRemove.Enabled = False
            End If
      End If
josephbupe is offline   Reply With Quote
Old Today, 08:07 AM   #18
josephbupe
Newly Registered User
 
Join Date: Jan 2008
Posts: 224
Thanks: 32
Thanked 1 Time in 1 Post
josephbupe is on a distinguished road
Re: Lock editing based on date and time elapsed

Quote:
Originally Posted by Minty View Post
Couldn't the time 20 minutes ago simply be
Code:
TwentyMinutesToComply: Dateadd("n",-20,Now())
Or have I used Monday logic and oversimplified?

Yeah thank you.

josephbupe is offline   Reply With Quote
Old Today, 08:16 AM   #19
ridders
Newbee moderator
Gold Supporter
 
ridders's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 5,532
Thanks: 79
Thanked 1,368 Times in 1,277 Posts
ridders is a jewel in the rough ridders is a jewel in the rough ridders is a jewel in the rough ridders is a jewel in the rough
Re: Lock editing based on date and time elapsed

You're welcome but I suggest you replace my dteDate expression with Minty's version
DteDate= Dateadd("n" -20,Now())

That will be much easier to alter if you decide to change from 20 mins to something else later on.

__________________
Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left and leave a comment.

New example databases:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


-------------------------
nil illegitimi carborundum est
ridders is offline   Reply With Quote
Reply

Tags
date and time

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating elapsed time within a time period cdoner Modules & VBA 4 12-02-2013 08:04 PM
Time Elapsed Djblois Modules & VBA 2 04-22-2009 08:24 AM
Elapsed time hbtousa Queries 4 11-05-2008 08:16 AM
Run Time has Elapsed LynnEsther General 4 06-10-2008 11:15 AM
Elapsed time eps General 5 10-16-2006 08:38 AM




All times are GMT -8. The time now is 04:04 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World