473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help w/ Calculated Fields

NatronA111
I am having a problem with calculated fields (...the most important one in the database!) in an MS Access query that pulls info from one table and a few other calculated fields stored in other queries.

[ExpectedPmt] simply adds the values of several fields for each record:

ExpectedPmt: CLng([InterceptScore]+[StateScore]+[EmploymentScore]+
[HomePhoneScore]+[WorkPhoneScore]+[BirthdateScore]+[GenderScore]+
[CustomerTypeScore]+[AccountStatusScore]+[BalanceScore]+
[InterestRateScore]+[LastPmtAmtScore]+[LastPmtDateScore]+
[LastContactDateScore]+[OtherObligationsScore]+[RentOwnScore])


[Score] then gives each record a "score" based on predetermined ranges for [ExpectedPmt]:

Score: CLng(IIf([ExpectedPmt]<="0","0",IIf([ExpectedPmt]>"0" And [ExpectedPmt]<"50","1",IIf([ExpectedPmt]>="50" And [ExpectedPmt]<"100","2",IIf([ExpectedPmt]>="100" And [ExpectedPmt]<"250","3",IIf([ExpectedPmt]>="250" And [ExpectedPmt]<"500","4",IIf([ExpectedPmt]>="500" And [ExpectedPmt]<"750","5",IIf([ExpectedPmt]>="750" And [ExpectedPmt]<"1000","6","7"))))))))

Based on the above, I would expect values of "73", "397", "772", and "1056" for [ExpectedPmt] to return values of "2", 4", 6", and "7" for [Score], respectively.

However, the query returns values of "5", "1", "7", and "1" for [Score], respectively. It seems that in the equation for [Score] it is only reading the first digit for both the value of [ExpectedPmt] and criteria value in the IIf statements.

Any help would be greatly appreciated.

FYI - My user skill-level is low and I have no programming experience...
Oct 5 '07 #1
3 1373
mlcampeau
296 Expert 100+
I am having a problem with calculated fields (...the most important one in the database!) in an MS Access query that pulls info from one table and a few other calculated fields stored in other queries.

[ExpectedPmt] simply adds the values of several fields for each record:

ExpectedPmt: CLng([InterceptScore]+[StateScore]+[EmploymentScore]+
[HomePhoneScore]+[WorkPhoneScore]+[BirthdateScore]+[GenderScore]+
[CustomerTypeScore]+[AccountStatusScore]+[BalanceScore]+
[InterestRateScore]+[LastPmtAmtScore]+[LastPmtDateScore]+
[LastContactDateScore]+[OtherObligationsScore]+[RentOwnScore])

[Score] then gives each record a "score" based on predetermined ranges for [ExpectedPmt]:

Score: CLng(IIf([ExpectedPmt]<="0","0",IIf([ExpectedPmt]>"0" And [ExpectedPmt]<"50","1",IIf([ExpectedPmt]>="50" And [ExpectedPmt]<"100","2",IIf([ExpectedPmt]>="100" And [ExpectedPmt]<"250","3",IIf([ExpectedPmt]>="250" And [ExpectedPmt]<"500","4",IIf([ExpectedPmt]>="500" And [ExpectedPmt]<"750","5",IIf([ExpectedPmt]>="750" And [ExpectedPmt]<"1000","6","7"))))))))

Based on the above, I would expect values of "73", "397", "772", and "1056" for [ExpectedPmt] to return values of "2", 4", 6", and "7" for [Score], respectively.

However, the query returns values of "5", "1", "7", and "1" for [Score], respectively. It seems that in the equation for [Score] it is only reading the first digit for both the value of [ExpectedPmt] and criteria value in the IIf statements.

Any help would be greatly appreciated.

FYI - My user skill-level is low and I have no programming experience...
The only thing that I can see right now is that in your Score calculation, you have quotes around all your numbers. Numbers don't need quotes around them so remove them and see what happens. (I don't know if that will make any difference but it's worth a shot)
Oct 5 '07 #2
The only thing that I can see right now is that in your Score calculation, you have quotes around all your numbers. Numbers don't need quotes around them so remove them and see what happens. (I don't know if that will make any difference but it's worth a shot)
Thanks...you rock! Taking the quotes out worked...
Oct 5 '07 #3
mlcampeau
296 Expert 100+
Thanks...you rock! Taking the quotes out worked...
Glad it worked for you!
Oct 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Wayne Aprato | last post by:
I have a simple database which was originally written in Access 97. When converted to Access 2000 file format it ran flawlessly in Access 2002. I've just tried to run it in Access 2003 and I am...
15
by: Colin | last post by:
I have a query that calculates the selling price of products on customer orders. Selling prices are calculated based on the average cost of the items when purchased. As I make new purchases, the...
9
by: Tony Williams | last post by:
I have two tables 1.tblmonth which holds two fields txtmonth and txtqtrlabel and 2. tblmain which holds a number of fields but in particular a field called txtqtrlabel2. The two tables are linked...
2
by: david | last post by:
Hi, I have a form with a couple of calculated fields. I want to put some code into the 'Form-Load' event to set various object states on the form, depending on the value of these fields. The...
2
by: Ryker | last post by:
I have a Purchase Order where I have a calculated field called Price that is calculated by multiplying Qty * Sales Price. I have 10 of these fields...Price 1 - Price 10 (for each line of the PO). ...
5
by: Henrik | last post by:
The problem is (using MS Access 2003) I am unable to retrieve long strings (255 chars) from calculated fields through a recordset. The data takes the trip in three phases: 1. A custom public...
2
by: jcf378 | last post by:
hi all. I have a form which contains a calculated control ("days") that outputs the # of days between two dates (DateDiff command between the fields and ). However, when I click "Filter by...
3
by: Matthew Wells | last post by:
If I have a calculated field that returns a value from a udf, does that field get calculated even when it's not being used in a Select statement? I knw that if a calculated field's formula is...
2
by: mkbrady | last post by:
I have a query that includes calculated fields that generate numeric results. I have wrapped conversion functions CLng() and CDdl() around the calculated fields to ensure the data types are...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.