Solved

Passcode to delete a record

Posted on 2014-02-05
3
292 Views
Last Modified: 2014-02-05
Is there a way have to enter a password in order to delete a record? This password doesn't have to be secure at all (just more of a process). I have using the below code for a password to change an item on this form. If they were to delete the entire record, can I have it ask for the same password (which is the booking number - 111*2)?

Thanks!

Private Sub ItemPrice_BeforeUpdate(Cancel As Integer)
Dim strCorrectPassword As String

strCorrectPassword = Abs(Me.BookNumber - 1111) * 2

If Forms![MainForm]![Bookings subform].Form![DateRecorded] < Date - 1 Then    'Reads in a date field on your from called "Some Date"
    If InputBox("Enter Password") <> strCorrectPassword Then 'Compares passwords
        Cancel = True
        MsgBox "Change not allowed without valid password.", vbOKOnly
        Me.ItemPrice.Undo 'undo recent change to this field
        Exit Sub
    End If
End If
End Sub
0
Comment
Question by:cansevin
3 Comments
 
LVL 75
ID: 39836995
For starters, seems you would want this code in the Form's Before Del Confirm event - which can also  be cancelled.

mx
0
 
LVL 10

Accepted Solution

by:
Gozreh earned 500 total points
ID: 39837005
Private Sub Form_Delete(Cancel As Integer)
   Dim strCorrectPassword As String
   strCorrectPassword = Abs(Me.BookNumber - 1111) * 2
   If Forms![MainForm]![Bookings subform].Form![DateRecorded] < Date - 1 Then    'Reads in a date field on your from called "Some Date"
       If InputBox("Enter Password") <> strCorrectPassword Then 'Compares passwords
           Cancel = True
           MsgBox "can not delete without valid password.", vbOKOnly
           Exit Sub
       End If
   End If
End Sub

Open in new window

0
 

Author Closing Comment

by:cansevin
ID: 39837019
Thanks!!!
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question