?
Solved

Passcode to delete a record

Posted on 2014-02-05
3
Medium Priority
?
299 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

839 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