Solved

how to count occurance of field

Posted on 2012-03-24
11
328 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 119

Expert Comment

by:Rey Obrero
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
 

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 119

Expert Comment

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


select [LARRECVDATE], IIF([LARRECVDATE] & ""<>"",2*25,Null)
From TableName
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

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

still giving me a syntax error.
0
 
LVL 119

Expert Comment

by:Rey Obrero
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 119

Expert Comment

by:Rey Obrero
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 119

Accepted Solution

by:
Rey Obrero 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

911 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now