Solved

Passcode to delete a record

Posted on 2014-02-05
3
289 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now