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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Msg executing cancel in textbox

Status
Not open for further replies.

aslrunner

Programmer
Jul 28, 2010
3
US
I have a textbox on a form with the following code for preventing data entry that doesn't meet certain criteria. However, whenever it exits this procedure I get the Error 3270 "Property not found" error. It only shows up if the Cancel = True command is executed. If it's not there the if statement will execute but the error message will not display. I am using Access 2007 but programming for 2003 use. Any suggestions of what I'm doing wrong?

Private Sub TQty1_BeforeUpdate(Cancel As Integer)
If (TQty1 >= TQty2 And TQty2 <> "") Or (TQty1 = "" And TQty2 <> "") Then
MsgBox "Qty1 must be < Qty2!", vbCritical, "INPUT ERROR"
Cancel = True
End If
End Sub

aslrunner
 


Cancel As Integer?

Boolean! is True/False

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Interesting observation SkipVought; however, I find that is how Microsoft uses it per their help files:

Private Sub ProductName_BeforeUpdate(Cancel As Integer)
If(Not IsNull(DLookup("[ProductName]", _
"Products", "[ProductName] ='" _
& Me!ProductName & "'"))) Then
MsgBox "Product has already been entered in the database."
Cancel = True
Me!ProductName.Undo
End If
End Sub

By the way, the integer thought doesn't work either.

aslrunner
 
I found a workaround for this problem, should anyone else come across it. From reading other posts on the internet, this seems to be an issue when viewing the form in Datasheet view. Instead of using Cancel = true, use DoCmd.cancelevent. This works for me.

Thanks for your help, Skip.

aslrunner
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top