[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Form_BeforeDelConfirm and Form_Delete

Posted on 2009-12-18
13
Medium Priority
?
949 Views
Last Modified: 2013-11-28
I am experiencing some inconsistency when coding these Events in Access 2007.
I have a Form "People" that has a subform "Roles". Using the right-click approach, I am deleting Roles from an individual Person. There are occasions when the Form_DeleteEvent is not triggered in the VBA code of the subform and the Form_BeforeDelConfirm Event is executed. I am trying to work out under which circumstances this happens, meanwhile I am wondering if anyone else has a similar experience.
So far, I suspect this sequence maybe due to me Opening the People Form from another Form. This code is included.

Private Sub txtName_DblClick(Cancel As Integer)
If Not (IsNull(txtName) Or txtName = 0) Then
    If Application.CurrentProject.AllForms("People").IsLoaded Then _
        DoCmd.Close acForm, "People", acSavePrompt
    DoCmd.OpenForm "People", , , "ID = " & ID, acFormEdit, acDialog, "Open<"
    blnFullForm = False     ' Set the indicator for not haing all Navigation controls
End If
Me.Refresh
End Sub

Open in new window

0
Comment
Question by:Henry_Harris
  • 9
  • 3
13 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 26079216
Are you using a multi-value field  .value to generate the subform?

If so, then when you 'delete' you are not deleting a record, you are only removing a value from the multi-value field.
0
 

Author Comment

by:Henry_Harris
ID: 26079256
Thank you for your post.
No, I am not using a multi-value field .value to generate the subform. The subform is bound to a table, which has two fields, the ID of the People Record and the ID of of the Role Record to get the text of the Role.
The Role Form Record Source is:
SELECT tblPeopleWithRoles.PeopleID, tblPeopleWithRoles.RoleID
FROM tblRoles INNER JOIN tblPeopleWithRoles ON tblRoles.ID = tblPeopleWithRoles.RoleID
ORDER BY tblRoles.Role;
The Role FIeld in the Form's Record Source is:
SELECT tblRoles.ID, tblRoles.Role
FROM tblRoles;

Open in new window

0
 

Author Comment

by:Henry_Harris
ID: 26079680
I have deloped a workaround, which stops right-Clicking when the People Form is opened by another Form. I did it this way as the subForm is opened first. What do you think? Have you any alternatives.
Private Sub Form_Open(Cancel As Integer)

' Check whether to allow shortcut menus
If Len(Form.Parent.OpenArgs) > 0 Then   ' Opening from another Form

    Form.ShortcutMenu = False
    
Else
    
    Form.ShortcutMenu = True
    
End If

End Sub

Open in new window

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

Author Comment

by:Henry_Harris
ID: 26079711
As an added worry, I have other forms that have subforms and whcih can be opened form other Forms. I have not had a similar problem, yet!
0
 

Author Comment

by:Henry_Harris
ID: 26086374
I rebult the Roles subform and the symptom is still there
0
 
LVL 3

Expert Comment

by:bobby6055
ID: 26086456
Henry_Harris:
For best result you can achieve the same thing by simply doing this:
Select "Tools -----> Startup
...and the following

(a).   Uncheck the checkbox "Use access special keys",
(b).   Uncheck the checkbox "Allow built in tool bars
(c).   Uncheck the checkbox "Allow full Menus
You can do this to all the tools in the startup a you deem fit.

Test you form I am sure this will do it.


Cheers !!!

Bobby
0
 

Author Comment

by:Henry_Harris
ID: 26086653
Thank you for your post and your suggestion.
My query is to find whether anyone has had similar experiences that I mentioned earlier with the Form_BeforeDelConfirm and Form_Delete Events
0
 
LVL 3

Expert Comment

by:bobby6055
ID: 26086929
Ok:
In other to understand this special circumstances, try to upload a smaller sample for experts to visualize the problem.
 
Bobby
0
 

Author Comment

by:Henry_Harris
ID: 26090670
Thank you for your post.
Whilst I understand your request, fulfilling it would not answer my query, which was has anyone had similar experiences of occasions when the Form_DeleteEvent is not triggered in the VBA code of the subform and the Form_BeforeDelConfirm Event is executed
0
 
LVL 3

Expert Comment

by:bobby6055
ID: 26090955
There are times where posting a small upload will assist experts in visualising the problem. It's up to you.
0
 

Accepted Solution

by:
Henry_Harris earned 0 total points
ID: 26091249
I understand. I'll work on it.
0
 

Author Comment

by:Henry_Harris
ID: 26120041
I have found a related situation that explains the symptom.
In my case it appears that wehn you have both Form_Delete and Form_BeforeDelConfirm Events, they can be triggered in different order as explained in the article - http://support.microsoft.com/default.aspx?scid=kb;en-us;234866.
I can get that situation when I access a Form from another by "DoCmd.OpenForm" when compared to opening the Form directly.
A solution is to remove the Form_Delete Event!
0
 

Author Comment

by:Henry_Harris
ID: 29347260
A test of an upload
cookies.txt
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

I have had my own IT business for a very long time. I started mostly with hardware and after about a year started to notice a common theme. I had shelves with software boxes -- Peachtree, Quicken, Sage, Ouickbooks -- and yet most of my clients were…
A Case Study of using the Windows API to provide RS232 communications capability in Access without the use of Active-X controls.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

607 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