Link to home
Start Free TrialLog in
Avatar of WoodrowA
WoodrowAFlag for United States of America

asked on

Property not found error in BeforeUpdate event

I am using Access 2007:

I am using Access 2007:

My problem has to do with BeforeUpdate Event associated with a textbox on a datasheet. following the Cancel = True code, the application brings up a dialog of Error 3270 Property not found.  It is not possible to trap for the error.  I even switched my setting in VBA to Break on All errors and it still will not stop to tell me where exactly the error is coming from.  Just wondering if anyone has any ideas.  My code (in the BeforeUpdate event of the text box) follows.


Dim Msg, Style, Title, Help, MyString, Response
    On Error GoTo Error_Trap
    If Me.txtNetWt = "" Then  'Continue on.  Do nothing
    Else
    
       
        Msg = "You are about to change a value that affects the Weight fields.  If you continue Qty and NetWt and GrosWT fields will be blanke." _
       & vbCrLf _
       & vbCrLf _
       & "Is this what you want?"
        Style = vbYesNo + vbDefaultButton2
        Title = "Question"
        Response = MsgBox(Msg, Style, Title)
        If Response = vbYes Then
         'continue on
        Else
            Me.txtSize.Undo
            Cancel = True
        End If
    End If
    
Exit_Error:
    Exit Sub
    
Error_Trap:
       
    If Err.Number = 3270 Then     'Property not found
       Resume Next
    Else
      MsgBox "Error #" & Err.Number & ": " & Err.Description & ". Wdy code. See brnRetrieve_Click "
      Resume Exit_Error
    End If

Open in new window

Avatar of thenelson
thenelson

Single step though the code to see what is creating the error.
Avatar of WoodrowA

ASKER

Thank you for responding.
As I tried to communicate in my original post, single stepping does not work.  Apparently the error happens after the end sub of the BeforeUpdate Event and Access gives no indication as to why or where or how.  Single stepping does not work.
Try remarking out the line:
On Error GoTo Error_Trap
and running the code.

If that doesn't display the error try decompiling/recompiling:
CREATE A BACKUP OF THE CORRUPT DATABASE. (Just in case)

decompile: in run: msaccess "dbPathName.mdb" /decompile
   Compact/repair:  in run: msaccess "dbPathName.mdb" /compact
   compile: in VB editor: debug> compile
   Compact/repair
   http://www.granite.ab.ca/access/decompile.htm

BTW: you can replace    
If Me.txtNetWt = "" Then  'Continue on.  Do nothing
    Else
...
End If
With
If Me.txtNetWt = "" Then  Exit Sub
It would be easier to follow also.
I would also change it to:
If Len(Me.txtNetWt & "") = 0 Then  Exit Sub
A few microseconds faster and traps Nulls also.
ASKER CERTIFIED SOLUTION
Avatar of WoodrowA
WoodrowA
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial