Solved

how to count occurance of field

Posted on 2012-03-24
11
339 Views
Last Modified: 2012-03-24
In access I have a table and within a QUery I want to check to see if a field is not Null and if so multiple 2 x 25).

So if [LarRecvDate] is not null then write 2 *25.

What would the syntax in the query be?
0
Comment
Question by:seamus9909
  • 5
  • 5
11 Comments
 
LVL 6

Expert Comment

by:worthyking1
ID: 37760779
You're going to need to be a bit more specific on exactly what you're trying to do in order for us to help you.
0
 

Author Comment

by:seamus9909
ID: 37760798
ok in the row from the table I want to evaluate.

A field called  "LarRecved" can be null or not null.
if the field is not null I want to calculate using an expression in the query.

So if LarRecved is not null multiply 2 *25.

Does this help?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37760982
select [LarRecved], IIF([LarRecved] & ""<>"",2*25,Null)
from tableX


why not just use 50 instead of 2 * 25


post sample values from field LarRecved  and the result you expect to get when LarRecved  is NOT null and when LarRecved is NULL
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

by:seamus9909
ID: 37761054
So either there is a date in LARRECVDATE or its empty


select [LARRECVDATE], IIF([LARRECVDATE] & ""<>"",2*25,Null)


I could just enter 50 that is true.  When I entered the above syntax it is giving me an error .

I am missing something?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37761059
you have to include the "From TableName"


select [LARRECVDATE], IIF([LARRECVDATE] & ""<>"",2*25,Null)
From TableName
0
 

Author Comment

by:seamus9909
ID: 37761070
Owed: select[LARRECVDATE], IIF([LARRECVDATE] & ""<>"",1*25,Null) from tblclaim1

still giving me a syntax error.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37761071
copy this as the one COMPLETE query

select [LARRECVDATE], IIF([LARRECVDATE] & ""<>"",1*25,Null) as Owed
from tblclaim1

OR post the whole query you are using
0
 

Author Comment

by:seamus9909
ID: 37761079
Here you go


SELECT tblClaim1.ClaimID, tblClaim1.ClaimNo, tblClaim1.Claimant, tblClaim1.LARRECVDATE, tblEorRecvd.EORRecDate
FROM tblClaim1 INNER JOIN tblEorRecvd ON tblClaim1.ClaimID = tblEorRecvd.ClaimID
select [LARRECVDATE], IIF([LARRECVDATE] & ""<>"",1*25,Null) as Owed
from tblclaim1;
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37761082
here is the query


SELECT tblClaim1.ClaimID, tblClaim1.ClaimNo, tblClaim1.Claimant, tblClaim1.LARRECVDATE, tblEorRecvd.EORRecDate, IIF(tblClaim1.[LARRECVDATE] & ""<>"",1*25,Null) as Owed
FROM tblClaim1 INNER JOIN tblEorRecvd ON tblClaim1.ClaimID = tblEorRecvd.ClaimID
from tblclaim1;
0
 

Author Comment

by:seamus9909
ID: 37761104
It says syntax error missing operator when I try and run it
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 37761111
oops, sorry, copied the wrong one


SELECT tblClaim1.ClaimID, tblClaim1.ClaimNo, tblClaim1.Claimant, tblClaim1.LARRECVDATE, tblEorRecvd.EORRecDate, IIF(tblClaim1.[LARRECVDATE] & ""<>"",1*25,Null) as Owed
FROM tblClaim1 INNER JOIN tblEorRecvd ON tblClaim1.ClaimID = tblEorRecvd.ClaimID
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access Update Query 1 20
SQL Server 2012 r2 - Varible Table 3 23
SQL multicriteria from ONE textbox 32 42
T-SQL: New to using transactions 9 22
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question