Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-16-2018, 06:17 AM   #16
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 6,552
Thanks: 88
Thanked 1,609 Times in 1,499 Posts
isladogs is just really nice isladogs is just really nice isladogs is just really nice isladogs is just really nice isladogs is just really nice
Re: Lock editing based on date and time elapsed

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

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

Web links:
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.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin
Previously known as ridders

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.
isladogs is offline   Reply With Quote
Old 07-16-2018, 07:16 AM   #17
josephbupe
Newly Registered User
 
Join Date: Jan 2008
Posts: 225
Thanks: 33
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 07-16-2018, 08:07 AM   #18
josephbupe
Newly Registered User
 
Join Date: Jan 2008
Posts: 225
Thanks: 33
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 07-16-2018, 08:16 AM   #19
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 6,552
Thanks: 88
Thanked 1,609 Times in 1,499 Posts
isladogs is just really nice isladogs is just really nice isladogs is just really nice isladogs is just really nice isladogs is just really nice
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.
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Web links:
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.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin
Previously known as ridders

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.
isladogs is offline   Reply With Quote
The Following User Says Thank You to isladogs For This Useful Post:
josephbupe (07-17-2018)
Old 07-17-2018, 01:14 AM   #20
josephbupe
Newly Registered User
 
Join Date: Jan 2008
Posts: 225
Thanks: 33
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 ridders View Post
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.

Yeah, it that already.


Thanks alot

josephbupe 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:53 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