Solved Being able to disallow data entry (1 Viewer)

PaquettePaul

Member
Local time
Today, 14:42
Joined
Mar 28, 2022
Messages
107
Until the 5th day of the current month when the tax calculations are generated for the prior month, the user is able to change or delete any invoice information for that period. Once the cutoff is reached, I would like to allow the users to view the information but not make any changes whatsoever to records in the prior months. I could go through a process of protecting every field on every subform when those records are selected although I was wondering whether there is a cleaner/easier method. Any suggestions,
 

KitaYama

Well-known member
Local time
Tomorrow, 03:42
Joined
Jan 6, 2022
Messages
1,540
In cases like this, I don't bother with controls or fields. I use form or subform's BeforeUpdate event.
Users are allowed to change everything. But it will never be saved.
If you like you can add a messagebox to warn them the changes were not saved.

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
 
    If myCondition = True Then
        Me.Undo
        Cancel = True
    End If
  
End Sub
 

PaquettePaul

Member
Local time
Today, 14:42
Joined
Mar 28, 2022
Messages
107
That would work 😂😂

thanks
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 13:42
Joined
Feb 28, 2001
Messages
27,172
There is also the possibility from your description that in the form's OnCurrent event, you test the day's date against the date on the record and then according to the results, diddle with the form's .Allowxxxx flags. You can start with


And from that page, on the left you can easily get to the .AllowDeletions, .AllowEdits, and any other things you might wish to set or clear. That would be fairly decent as a way to try to block certain actions.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:42
Joined
Feb 19, 2002
Messages
43,257
I don't like using the Allowxxxx options because it interferes with search boxes if the form has any. I use @KitaYama 's method.
 

Users who are viewing this thread

Top Bottom