Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Passcode to delete a record

Posted on 2014-02-05
3
Medium Priority
?
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

610 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