|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
I created an employee form which allows the user to delete the employee by hitting a command button. The code behind the command button then deletes the employee as well as all of the supporting tables.
How can I prevent the user from deleting the record with the delete key, so the system is forced to delete the supporting tables ?
|
|
I don't get it... You might want to clarify your question... Sounds like you want the delete key just to get rid of the tables??? not sure why you would want the tables deleted, perhaps you meant record???
AND say how your tables are set up, sounds like they support cascading deletes but can't be sure if you even have it enforced.
HTH, Gina Whipp
"rmcompute" <rmcompute[ at ]discussions.microsoft.com> wrote in message news:CA681544-7A76-481B-B171-C5DF05B28A05[ at ]microsoft.com...
[Quoted Text] >I created an employee form which allows the user to delete the employee by > hitting a command button. The code behind the command button then > deletes > the employee as well as all of the supporting tables. > > How can I prevent the user from deleting the record with the delete key, > so > the system is forced to delete the supporting tables ?
|
|
I don't want the user to be able to put the cursor on the record of the form and press the delete key on the keyboard of the computer. When this happens, the record is deleted from the current table. I set up a command button on the form which I want the user to use to delete a record. When that key is pressed, the record is deleted from the current table, but also there is code behind the command button which deletes various records in other tables and performs other clean-up processes. Since there is no way to prevent the user from pressing the delete key on the computer, do you know how to determine if it was pressed and perhaps display an error message and prevent the user from deleting the record in this way ?
"Gina Whipp" wrote:
[Quoted Text] > I don't get it... You might want to clarify your question... Sounds like > you want the delete key just to get rid of the tables??? not sure why you > would want the tables deleted, perhaps you meant record??? > > AND say how your tables are set up, sounds like they support cascading > deletes but can't be sure if you even have it enforced. > > HTH, > Gina Whipp > > > "rmcompute" <rmcompute[ at ]discussions.microsoft.com> wrote in message > news:CA681544-7A76-481B-B171-C5DF05B28A05[ at ]microsoft.com... > >I created an employee form which allows the user to delete the employee by > > hitting a command button. The code behind the command button then > > deletes > > the employee as well as all of the supporting tables. > > > > How can I prevent the user from deleting the record with the delete key, > > so > > the system is forced to delete the supporting tables ? > > >
|
|
First, is the form a continuous or single? And is the form’s property “Record Selectors†= Yes?
If “Record Selectors†is No, the user can only edit data. The “Delete†or “Del†key is only use for edit in this case.
If Yes, you’ll need the “Form_KeyDown Event†to reset the keys.
Depending on the type of keyboard, you’ll need to determine which key can delete the record.
‘use this in the keydown event of your form ‘use debug to check the number, delete after using Debug.Print KeyCode ‘ use to check the KeyCode number ‘US keyboard 101 type Select Case KeyCode Case 46 ‘Delete Key number, “Del†is 110 ‘MsgBox “Your message here if needed†‘reset keycode KeyCode = 0 End Select
-- Message posted via http://www.accessmonster.com
|
|
Set the form's AllowDelete property to 0 (False) In the GUI, you'll find this on the Data tab of the properties window. -- Ted
|
|
I don't believe that will work because when you want to delete a record you can't. AccessVandal has the best solution so far.
Gina Whipp
"tedmi" <tedmi[ at ]discussions.microsoft.com> wrote in message news:17F7F6FF-C504-4FA2-AC6F-8F1539C8E187[ at ]microsoft.com...
[Quoted Text] > Set the form's AllowDelete property to 0 (False) > In the GUI, you'll find this on the Data tab of the properties window. > -- > Ted
|
|
Worked like a charm.
Thank you.
"AccessVandal via AccessMonster.com" wrote:
[Quoted Text] > First, is the form a continuous or single? And is the form’s property “Record > Selectors†= Yes? > > If “Record Selectors†is No, the user can only edit data. The “Delete†or > “Del†key is only use for edit in this case. > > If Yes, you’ll need the “Form_KeyDown Event†to reset the keys. > > Depending on the type of keyboard, you’ll need to determine which key can > delete the record. > > ‘use this in the keydown event of your form > ‘use debug to check the number, delete after using > Debug.Print KeyCode ‘ use to check the KeyCode number > ‘US keyboard 101 type > Select Case KeyCode > Case 46 ‘Delete Key number, “Del†is 110 > ‘MsgBox “Your message here if needed†> ‘reset keycode > KeyCode = 0 > End Select > > -- > Message posted via http://www.accessmonster.com> >
|
|
I agree; AccessVandal's solution worked.
"Gina Whipp" wrote:
[Quoted Text] > I don't believe that will work because when you want to delete a record you > can't. AccessVandal has the best solution so far. > > Gina Whipp > > > "tedmi" <tedmi[ at ]discussions.microsoft.com> wrote in message > news:17F7F6FF-C504-4FA2-AC6F-8F1539C8E187[ at ]microsoft.com... > > Set the form's AllowDelete property to 0 (False) > > In the GUI, you'll find this on the Data tab of the properties window. > > -- > > Ted > > >
|
|
Don't forget, however, that if Num Lock is off, there are TWO delete keys on the keyboard. And will it work on every laptop keyboard? And what if the user clicks the delete button on the toolbar? Deletes will always work, regardless of AllowDeletions property, if executed with a Delete query, rather than the DoCmd code produced by the Command Button delete wizard. But if you insist on the wizard code, wrap it in code that sets then resets the AllowDeletions property:
Private Sub ButtonName_Click Me.AllowDeletions = True ' do the deletes and cleanup here Me.AllowDeletions = False End Sub -- Ted
"rmcompute" wrote:
[Quoted Text] > I agree; AccessVandal's solution worked. > > "Gina Whipp" wrote: > > > I don't believe that will work because when you want to delete a record you > > can't. AccessVandal has the best solution so far. > > > > Gina Whipp > > > > > > "tedmi" <tedmi[ at ]discussions.microsoft.com> wrote in message > > news:17F7F6FF-C504-4FA2-AC6F-8F1539C8E187[ at ]microsoft.com... > > > Set the form's AllowDelete property to 0 (False) > > > In the GUI, you'll find this on the Data tab of the properties window. > > > -- > > > Ted > > > > > >
|
|
No point creating a button. Just set the form's property Data tab - "Allow Deletions" = No.
That will depends on how he'll design the database.
Menus and toolbars can be disable. Even the Querys and VBA Editor can be remove.
You can use the security to lock the table and records form deletion.
TedMi wrote:
[Quoted Text] >Don't forget, however, that if Num Lock is off, there are TWO delete keys on >the keyboard. And will it work on every laptop keyboard? And what if the user >clicks the delete button on the toolbar? >Deletes will always work, regardless of AllowDeletions property, if executed >with a Delete query, rather than the DoCmd code produced by the Command >Button delete wizard. But if you insist on the wizard code, wrap it in code >that sets then resets the AllowDeletions property: > >Private Sub ButtonName_Click > Me.AllowDeletions = True > ' do the deletes and cleanup here > Me.AllowDeletions = False >End Sub >> I agree; AccessVandal's solution worked. >> >[quoted text clipped - 7 lines] >> > > -- >> > > Ted
-- Message posted via http://www.accessmonster.com
|
|
|