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!

Sometimes my code works other times I have to Debug

Status
Not open for further replies.

idavis1900

Technical User
Dec 17, 2008
18
I have this code on a form, the me![percent] has a iff statment which is:
=([expenseItemAmount]-nz([ded],0))*IIf([ExpenseCategoryID]=3,0.5,0.8)
then I have this code on the form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me![ckamount] = Me![Percent]
Me![OONAmount] = IIf([OON] = -1, [ckamount], 0)
Me![RemAmount] = IIf([Rem] = -1, [ckamount], 0)

I'm getting a error

run-time 2465 can't find the field [percent] referred in your expression.

But I have also have gotten compile error variable not defined on the me![oonamount].

Any help will be appreciated.
 
Sometimes Access does not like it when the name of a control is exactly the same as one of the field names. Try changing the names of the controls and see if you have better luck.

I usually surround any reference to a control in code with Nz. It may solve you "variable not found" error.

Joe Schwarz
Custom Software Developer
 
percent" is a VBA reserved word. You shouldn't be using it as a variable or a field name.

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top