On Delete event procedure

inneed

New member
Local time
Today, 14:55
Joined
Jun 19, 2006
Messages
5
I am trying to figure out how to manipulate the On Delte event of a subform.
I can delete the record but I need to have fields on the main form reflect the changes. Can any one help me?

Error Message:
The expression On Delete you entered as the event property setting produced the following error: A problem occurred while Microsoft Access was communicating with the OLE server or ActiveX Control.
*The expression may not result in the name of a macro, thename of a user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.


Basically I think this message is telling me that I can not modify the deleting procedure as I wish too. If this is true can you tell me where I can do that.

here is the very basic code that i am using.

This is the subform code
Option Compare Database
Dim main As Form_frmOrders

Private Sub Form_Delete(Cancel As Integer)
On Error GoTo err
Dim wght As Double
Dim pallet As Double
wght = .Total_Weight.Value
pallet = main.Total_Pallets.Value
If Weight.Value <> 0 Then
wght = wght - Weight.Value
MsgBox wght
Else
pallet = pallet - Quantity.Value
MsgBox pallet
End If
err:
MsgBox err
Exit Sub
End Sub


Thank you,
Teri
 
Try making a fake code

Private Sub Form_Delete(Cancel As Integer)

MsgBox "OK"

End Sub


Will it show OK?
 
I see several issues. "err" is a reserved word not to be used carelessly.
List of reserved words in Access 2002 and Access 2003
List of Microsoft Jet 4.0 reserved words
Special characters that you must avoid when you work with Access databases
You should scope your control references with "Me.". Me scopes the reference to the form and makes whatever you were doing with the main variable unnecessary. e.g Me.Total_Pallets

The .Value property is the default property and as such need not be specified. So Me.Total_Pallets is the same as Me.Total_Pallets.Value
It make the code easier to read as far as I'm concerned.

You should name your controls different from the field to which they are bound so Access does not get confused (it happens).
LESZYNSKI (HUNGARIAN) NAMING CONVENTION

When you post code, surround it with the
Code:
tags
to preserve the indenting and readability.
Your code will always fall through the Error handler. You will want to revise it.
Make a few changes and let's see where we get.
 
Last edited:
Also, since there's no "With" statement active, the leading "." here is a problem:

wght = .Total_Weight.Value
 

Users who are viewing this thread

Back
Top Bottom