Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 12th, 2006, 09:31 AM
Registered User
 
Join Date: Apr 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default I want to add password for delete button in form.

so any other people will not accident delete the content. can any one help me how to do it?

Thanks

 
Old May 12th, 2006, 10:09 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Yes, on the On Click event of the delete button:

Dim sPass As String

sPass = InputBox("Please enter the password:")

If sPass <> "YourPassword" Then
   MsgBox "You cannot delete this item."
   Exit Sub
   Else
   '...carry out delete function
End If

If you don't want to put the password in plain text, you can put it in a hidden table, then launch a hidden form when the app opens, then do this:

Dim sPass1 As String
Dim sPass2 As String

sPass2 = [Forms]![frmHiddenPassword].[txtPassword]

sPass1 = InputBox("Please enter the password:")

If sPass1 <> sPass2 Then
   MsgBox "You cannot delete this item."
   Exit Sub
   Else
   '...carry out delete function
End If

HTH


mmcdonal
 
Old May 12th, 2006, 10:11 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Now I remember what I was gonna say:

I wouldn't delete content from any database if you can help it. I usually have a "retire" check box on each record so that the data no longer appears in the regular forms or reports ([Retired] = No) and the data is there if I need it.

HTH


mmcdonal
 
Old May 12th, 2006, 10:25 AM
Registered User
 
Join Date: Apr 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot!






Similar Threads
Thread Thread Starter Forum Replies Last Post
php/mysql delete button and delete query dungey PHP Databases 17 April 11th, 2009 12:24 PM
Add Push button or Check Box in outlook add-ins capdevs VS.NET 2002/2003 0 January 7th, 2006 08:51 AM
Re: Add button on a form with datasheet view lxu Access 5 March 8th, 2004 06:19 PM
battling to add username & password too similar... Greywacke Javascript 4 October 8th, 2003 02:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.