Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password Protecting Delete Function...

Status
Not open for further replies.

hgraybill

MIS
Mar 30, 2007
32
US
I want to password protect my delete command, so only users that know the correct password can delete the record. I'm really not sure how to go about this, because I'm still a beginner, but my code for the delete command is below.

Any help is appreciated!

Thanks,
Heather

'-----------------------------------------------------------------------------
Private Sub cmdDelete_Click()
'-----------------------------------------------------------------------------
On Error GoTo LocalError

If MsgBox("Are you sure you want to delete this record?", _
vbYesNo + vbQuestion, _
"Delete") = vbNo Then
Exit Sub
End If
mobjADORst.Delete
mobjADORst.Requery
'reposition after delete
mobjADORst.Find "ASSET_NUMBER > " & txtAssetNumber.Text
If mobjADORst.EOF Then mobjADORst.MoveLast
'load data
Call PopulateFormFields

Exit Sub

LocalError:
MsgBox Err.Number & " - " & Err.Description
End Sub
 
Commonly an input box (instead of a message box) is used to trap the password, validate it, and cancel the event as needed.

Money can't buy happiness -- but somehow it's more comfortable to cry in a Corvette than in a Yugo.
 
I have a program where I added a field called "bMarkForDeletion" and all I do when someone "Deletes" a record is mark the field.

The recordset that is pulled has them filtered out so as far as the user is concerned, it's gone. When I need to recover something that someone decided they needed back is un-mark it.

Just an idea.

 
I would also suggest that you become familiar with the more standard ways of securing delete access to data, as what you are proposing is very non-standard. It is very non-standard because it isn't the most efficient way to handle it enterprise-wide. Suppose you are a database administrator, and there are 1500 applications like this one in your enterprise, and you are responsible for them. Can you imagine what a headache it would be to have to go through every one of those applications and make sure that delete access is properly secured one way or another? In the end, there would have to be a hole somewhere.

So typically, this security access is handled outside of your program at the system level. Users belong to groups, and access is assigned to the group. Then your program can get feedback about whatever security access is currentlhy present, and act accordingly. For example, if you try to delete a record and the user doesn't have the rights to do so, you'll get an error (assuming that your connectionstring is using the "Integrated Security=SSPI" option).

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top