#Type! in calculated fields of a form (1 Viewer)

AlefAelol

Registered User.
Local time
Today, 16:16
Joined
May 21, 2014
Messages
75
I have a subform of some calculated fields that calculate date from other fields. I am getting "#Type!" error at the calculated fields. I did some searches and found that happens when trying to calculate different data types together, however, my fields to be calculated are all "NUMBER" data type. So, why I am getting this error please help, that error bring a big headache to me. Is there another reasons that cause "#Type!" to appear ? many thanks
 

Minty

AWF VIP
Local time
Today, 14:16
Joined
Jul 26, 2013
Messages
10,366
Without seeing what you are using as control sources for the controls, I'm afraid we'll all need a crystal ball to guess what the problem might be.

What's the code / expression / formula being used?
 

plog

Banishment Pending
Local time
Today, 08:16
Joined
May 11, 2011
Messages
11,638
I have a rusty crystal ball, accurate about 75% of the time. It's telling me you are not working with all NUMBER data types. I bet you are using a function that is returning a string and you just assume its a number, because, well; it looks like numbers.

I'm going to parlay my bet and say specifically its Format doing the deed.
 

Minty

AWF VIP
Local time
Today, 14:16
Joined
Jul 26, 2013
Messages
10,366
I'll get the glass polish out, it appears to be working :)
 

AlefAelol

Registered User.
Local time
Today, 16:16
Joined
May 21, 2014
Messages
75
Without seeing what you are using as control sources for the controls, I'm afraid we'll all need a crystal ball to guess what the problem might be.

What's the code / expression / formula being used?


Some beautiful minds work like crystal ball with accurate 100% :). The calculated filed I use is



Code:
=IIf([txtRes]=5 And [txtTotal2]<50,[ScndCrseFrstAsses]+[ScndCrseScndAsses],Null)


Details;
txtRes is also a calculated filed based on a function and this function returns only numbers. the txtTotal is bound to a query field. ScndCrseFrstAsses and ScndCrseScndAsses are data entry field bound to a query and both are NUMBER data type.
 

AlefAelol

Registered User.
Local time
Today, 16:16
Joined
May 21, 2014
Messages
75
What's the code / expression / formula being used?
This issue appears sometimes not all times, it happens when a user deletes date from the ScndCrseFrstAsses and ScndCrseScndAsses by the delete key
 

AlefAelol

Registered User.
Local time
Today, 16:16
Joined
May 21, 2014
Messages
75
I have a rusty crystal ball, accurate about 75% of the time. It's telling me you are not working with all NUMBER data types. I bet you are using a function that is returning a string and you just assume its a number, because, well; it looks like numbers.

I'm going to parlay my bet and say specifically its Format doing the deed.
I have some functions, but they are all return numbers
 

Minty

AWF VIP
Local time
Today, 14:16
Joined
Jul 26, 2013
Messages
10,366
Are there any Null values in any of the underlying data?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:16
Joined
Feb 28, 2001
Messages
27,131
The correct way to diagnose this is to put a breakpoint in the sub-form's Form_Current event so that the code stops right there. Then open an immediate window. Then use the command Debug.Print on each item you are using that comes from a field in order to contribute to your computation. Do this one contributor at a time.

If the item in question is a number, you would see, for example:

Debug.Print [control]
6


but if it is text, you would see

Debug.Print [control]
"6"


Those quotes around the answer would tell you which element isn't what you think it is.
 

isladogs

MVP / VIP
Local time
Today, 14:16
Joined
Jan 14, 2017
Messages
18,209
Try this

Code:
=IIf([txtRes]=5 And [txtTotal2]<50,Nz([ScndCrseFrstAsses],0)+Nz([ScndCrseScndAsses],0),Null)
 

AlefAelol

Registered User.
Local time
Today, 16:16
Joined
May 21, 2014
Messages
75
The correct way to diagnose this is to put a breakpoint in the sub-form's Form_Current event so that the code stops right there. Then open an immediate window. Then use the command Debug.Print on each item you are using that comes from a field in order to contribute to your computation. Do this one contributor at a time.

If the item in question is a number, you would see, for example:

Debug.Print [control]
6


but if it is text, you would see

Debug.Print [control]
"6"


Those quotes around the answer would tell you which element isn't what you think it is.
Many thanks, I will try your method to see what the wrong is
 

Users who are viewing this thread

Top Bottom