I have a subform with the following formula in a field:
ClassCache := “Notes” : “NoCache”;
ServerName := @Subset(@DbName;1);
LookUpDb := @Subset(@DbName;-1);
view := “luEqByPI”;
key := EventEquipNum;
fld := “Chemical1”;
ans := @DbLookup(ClassCache; ServerName : LookUpDb; view; key; fld);
@If(@IsError(ans) | (ans) = “”;0;(ans) * @If(EventEquipType = “Scrub Outage” ;FlDuration; EventDuration) / 60)
This works fine in another subform, but when I change to a new EventEquipType I get the dreaded number expected error. I’ve recreated the subform and went as far as rewriting the code, but have had no luck. Can someone give me any suggestions? I have searched and followed some of the advice I’ve found but nothing works. It’s just a copy of the formula that works on another subform.
Subject: SubForm Problem
Have you confirmed that FIDuration and EventDuration have a number value? If they are empty this type of error could appear. The only other thing I could think of is be sure “ans” (which is EventEquipNum) is returned as a number as well.
You can add this code to an action button and then do some testing with adding checks like @IsNumber on the fields.
Brent
Subject: RE: SubForm Problem
I’ll try your suggestions and post back. Thanks for the response!
Subject: RE: SubForm Problem
Everything is populating correctly.
Subject: RE: SubForm Problem
Looks like I meant “ans” should be the “Chemical1” field. Assuming that is a number as well then it is difficult to tell just based on that code. I see nothing wrong with the code right now. Maybe change ans=“” to @Text(ans)=“”.
I’m assuming that these fields are setup as “Number” fields as well?
Subject: RE: SubForm Problem
Got it! Set the default value of the FIDuration field to 0 and it worked. Thanks again.