Solved

how to count occurance of field

Posted on 2012-03-24
11
317 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Splitting out Data 14 27
How calculate median 5 38
SQL to update characters in table column 6 28
Access on thin client? 11 30
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

706 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

12 Experts available now in Live!

Get 1:1 Help Now