Please help 24 hours Me.AllowEdits

tanatif

Registered User.
Local time
Today, 15:42
Joined
Feb 10, 2016
Messages
40
please help me for this

Code:
--------------------------------------

Private Sub Form_Load()
Dim userLevel As Integer
userLevel = Forms![Navigation Form]!txtSecurity.Value
Call Security(userLevel)
End Sub

--------------------------------------

Sub Security(userLevel As Integer)
Select Case userLevel

    Case 1    'Admin has full control, no restriction

            
    Case 2  'view and edit
            Me.AllowDeletions = True
            Me.AllowAdditions = True
            Me.AllowEdits = True

End Select
End Sub
--------------------------------------


I wont userlevel 2 = > 24 hours Me.AllowEdits = False <=23 اhours Me.AllowEdits = True
remeber i have field CreationDate and FirstCreator for txtLogin

=[Forms]![Navigation Form]![txtLogin]

how can i control edite only for userlevel=2

thank you
 
I don't understand what you mean by
"I want userlevel 2 = > 24 hours Me.AllowEdits = False <=23 اhours Me.AllowEdits = True"

I want userlevel 2 to have edits enabled after 23 hours after something, or between 11pm and 12am?
 
I want to allow the edit only within 24 hours and not allow edit after a full day
 
"...and not allow edit after a full day"

When does a "full day" start? From the time the user opens the database? From 8.30am on Mondays? After the next public holiday?

If from the time the database is opened, you can store the start time when the database is opened and then use the timer event on a form which is opened in hidden mode at the start.
 
I think this is the logic you mean . . .
Code:
AllowEdits = CurrentDateTime < CreatedDateTime + 24 Hours
And for CurrentDateTime we can use VBA.Now(), and for "24 Hours" we can use 1 day, which is 1, then we can say . . .
Code:
Me.AllowEdits = Now() < CreatedDateTime + 1
. . . so all you need to do is replace the CreatedDateTime value in the expression to the CreatedDateTime of the row in question. You have indicated you have a field called CreationDate. Does it have the time included?
Does that help?
 
i try this and is working good

Code:
Private Sub Form_Load()
txtmove = Space(100) & DLast("strNews", "tblNews")
Dim userLevel As Integer
userLevel = Forms![Navigation Form]!txtSecurity.Value
Call Security(userLevel)
End Sub

Sub Security(userLevel As Integer)
Select Case userLevel

    Case 1    'Admin has full control, no restriction

    
    Case 2    'view and edit
            Dim Edits_Date As String
            Edits_Date = Forms![Navigation Form]!CreatedDateTime.Value
            If (Edits_Date < 1) Then
            Me.AllowEdits = True
            Me.AllowAdditions = True
            Me.AllowDeletions = False
            Else
            Me.AllowEdits = False
            Me.AllowAdditions = False
            Me.AllowDeletions = False
            End If


but i have big problem after i convert db to sql server

the date he is changed to longdate i wont it shortdate and i wont it hijri date how please help me for this step
 

Users who are viewing this thread

Back
Top Bottom