A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Query Question



 
 
Thread Tools Display Modes
  #1  
Old June 10th, 2009, 05:06 PM posted to microsoft.public.access
Jennie
external usenet poster
 
Posts: 55
Default Query Question

I have the following expression in my query:

Recent: Max(IIf([Current]=[PreviousDate]," ",""))

When I switch the "" and the " " it works perfectly but when I have the
Truepart set as " " all records have the "". I tried substituting " " with
another character and it works. I also tried using "" (no space) and it still
didn't work.

If you need a little background, this database tracks the 91 utility bills
we receive each month. Not all of the accounts are billed monthly, I want the
"" to appear next to the accounts that did not receive a bill for the
current period. Current is formatted as mm/yyyy and is set as month and year
of the most recent bill received for each account. PreviousDate is also
formatted as mm/yyyy and is set as the previous month and year (For example,
we receive May's bills in June, so if I were to run the report today then
PreviousDate would be 05/2009). If the two fields do not match, meaning no
bill was received in 05/2009, I want the "" to appear. If they do match,
then I don't want anything to appear. What am I doing wrong?
  #2  
Old June 10th, 2009, 05:38 PM posted to microsoft.public.access
Dorian
external usenet poster
 
Posts: 542
Default Query Question

very strange!
Did you try changing the "=" to "" and reversing the conditions?
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"Jennie" wrote:

I have the following expression in my query:

Recent: Max(IIf([Current]=[PreviousDate]," ",""))

When I switch the "" and the " " it works perfectly but when I have the
Truepart set as " " all records have the "". I tried substituting " " with
another character and it works. I also tried using "" (no space) and it still
didn't work.

If you need a little background, this database tracks the 91 utility bills
we receive each month. Not all of the accounts are billed monthly, I want the
"" to appear next to the accounts that did not receive a bill for the
current period. Current is formatted as mm/yyyy and is set as month and year
of the most recent bill received for each account. PreviousDate is also
formatted as mm/yyyy and is set as the previous month and year (For example,
we receive May's bills in June, so if I were to run the report today then
PreviousDate would be 05/2009). If the two fields do not match, meaning no
bill was received in 05/2009, I want the "" to appear. If they do match,
then I don't want anything to appear. What am I doing wrong?

  #3  
Old June 10th, 2009, 05:58 PM posted to microsoft.public.access
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Query Question

I do not understand your use of Max here.

Why not use it this way --
Recent: IIf([Current]=[PreviousDate], "", "")

and sort Descending?

"Jennie" wrote:

I have the following expression in my query:

Recent: Max(IIf([Current]=[PreviousDate]," ",""))

When I switch the "" and the " " it works perfectly but when I have the
Truepart set as " " all records have the "". I tried substituting " " with
another character and it works. I also tried using "" (no space) and it still
didn't work.

If you need a little background, this database tracks the 91 utility bills
we receive each month. Not all of the accounts are billed monthly, I want the
"" to appear next to the accounts that did not receive a bill for the
current period. Current is formatted as mm/yyyy and is set as month and year
of the most recent bill received for each account. PreviousDate is also
formatted as mm/yyyy and is set as the previous month and year (For example,
we receive May's bills in June, so if I were to run the report today then
PreviousDate would be 05/2009). If the two fields do not match, meaning no
bill was received in 05/2009, I want the "" to appear. If they do match,
then I don't want anything to appear. What am I doing wrong?

  #4  
Old June 10th, 2009, 06:29 PM posted to microsoft.public.access
ghetto_banjo
external usenet poster
 
Posts: 325
Default Query Question

I think the issue with the Max() function. Why not just the iif?

  #5  
Old June 10th, 2009, 06:42 PM posted to microsoft.public.access
Jennie
external usenet poster
 
Posts: 55
Default Query Question

Karl,

I use Max because the report shows all bills ever received for every
account. I only want to see if the most current billed date matches the
PreviousDate field, not all of the bills.

"KARL DEWEY" wrote:

I do not understand your use of Max here.

Why not use it this way --
Recent: IIf([Current]=[PreviousDate], "", "")

and sort Descending?

"Jennie" wrote:

I have the following expression in my query:

Recent: Max(IIf([Current]=[PreviousDate]," ",""))

When I switch the "" and the " " it works perfectly but when I have the
Truepart set as " " all records have the "". I tried substituting " " with
another character and it works. I also tried using "" (no space) and it still
didn't work.

If you need a little background, this database tracks the 91 utility bills
we receive each month. Not all of the accounts are billed monthly, I want the
"" to appear next to the accounts that did not receive a bill for the
current period. Current is formatted as mm/yyyy and is set as month and year
of the most recent bill received for each account. PreviousDate is also
formatted as mm/yyyy and is set as the previous month and year (For example,
we receive May's bills in June, so if I were to run the report today then
PreviousDate would be 05/2009). If the two fields do not match, meaning no
bill was received in 05/2009, I want the "" to appear. If they do match,
then I don't want anything to appear. What am I doing wrong?

  #6  
Old June 10th, 2009, 06:54 PM posted to microsoft.public.access
Jennie
external usenet poster
 
Posts: 55
Default Query Question

Dorian,

I tried that and I am still having the same problem. I have no idea what I
am doing wrong.

"Dorian" wrote:

very strange!
Did you try changing the "=" to "" and reversing the conditions?
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"Jennie" wrote:

I have the following expression in my query:

Recent: Max(IIf([Current]=[PreviousDate]," ",""))

When I switch the "" and the " " it works perfectly but when I have the
Truepart set as " " all records have the "". I tried substituting " " with
another character and it works. I also tried using "" (no space) and it still
didn't work.

If you need a little background, this database tracks the 91 utility bills
we receive each month. Not all of the accounts are billed monthly, I want the
"" to appear next to the accounts that did not receive a bill for the
current period. Current is formatted as mm/yyyy and is set as month and year
of the most recent bill received for each account. PreviousDate is also
formatted as mm/yyyy and is set as the previous month and year (For example,
we receive May's bills in June, so if I were to run the report today then
PreviousDate would be 05/2009). If the two fields do not match, meaning no
bill was received in 05/2009, I want the "" to appear. If they do match,
then I don't want anything to appear. What am I doing wrong?

  #7  
Old June 10th, 2009, 06:58 PM posted to microsoft.public.access
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Query Question

The Max as you are using it will not give you the latest date as it is not
perfoming a function on a date. It is giving you the Max of the IIF function.

"Jennie" wrote:

Karl,

I use Max because the report shows all bills ever received for every
account. I only want to see if the most current billed date matches the
PreviousDate field, not all of the bills.

"KARL DEWEY" wrote:

I do not understand your use of Max here.

Why not use it this way --
Recent: IIf([Current]=[PreviousDate], "", "")

and sort Descending?

"Jennie" wrote:

I have the following expression in my query:

Recent: Max(IIf([Current]=[PreviousDate]," ",""))

When I switch the "" and the " " it works perfectly but when I have the
Truepart set as " " all records have the "". I tried substituting " " with
another character and it works. I also tried using "" (no space) and it still
didn't work.

If you need a little background, this database tracks the 91 utility bills
we receive each month. Not all of the accounts are billed monthly, I want the
"" to appear next to the accounts that did not receive a bill for the
current period. Current is formatted as mm/yyyy and is set as month and year
of the most recent bill received for each account. PreviousDate is also
formatted as mm/yyyy and is set as the previous month and year (For example,
we receive May's bills in June, so if I were to run the report today then
PreviousDate would be 05/2009). If the two fields do not match, meaning no
bill was received in 05/2009, I want the "" to appear. If they do match,
then I don't want anything to appear. What am I doing wrong?

  #8  
Old June 10th, 2009, 07:09 PM posted to microsoft.public.access
Jennie
external usenet poster
 
Posts: 55
Default Query Question

Karl,

I tried to run the report with only this in the query:

Recent: IIf([Current][PreviousDate],"*","")

And I got an error message saying that the expression is not part of an
aggregate function. Did I enter it correctly? Thanks for your help.



"KARL DEWEY" wrote:

The Max as you are using it will not give you the latest date as it is not
perfoming a function on a date. It is giving you the Max of the IIF function.

"Jennie" wrote:

Karl,

I use Max because the report shows all bills ever received for every
account. I only want to see if the most current billed date matches the
PreviousDate field, not all of the bills.

"KARL DEWEY" wrote:

I do not understand your use of Max here.

Why not use it this way --
Recent: IIf([Current]=[PreviousDate], "", "")

and sort Descending?

"Jennie" wrote:

I have the following expression in my query:

Recent: Max(IIf([Current]=[PreviousDate]," ",""))

When I switch the "" and the " " it works perfectly but when I have the
Truepart set as " " all records have the "". I tried substituting " " with
another character and it works. I also tried using "" (no space) and it still
didn't work.

If you need a little background, this database tracks the 91 utility bills
we receive each month. Not all of the accounts are billed monthly, I want the
"" to appear next to the accounts that did not receive a bill for the
current period. Current is formatted as mm/yyyy and is set as month and year
of the most recent bill received for each account. PreviousDate is also
formatted as mm/yyyy and is set as the previous month and year (For example,
we receive May's bills in June, so if I were to run the report today then
PreviousDate would be 05/2009). If the two fields do not match, meaning no
bill was received in 05/2009, I want the "" to appear. If they do match,
then I don't want anything to appear. What am I doing wrong?

  #9  
Old June 10th, 2009, 08:39 PM posted to microsoft.public.access
ghetto_banjo
external usenet poster
 
Posts: 325
Default Query Question

Jennie,
Do you need to worry about just getting the Max of Current? Or both
Current and PreviousDate?

if only for current, try this:

Recent: IIf(Max([Current])=[PreviousDate]," ","")


You can't have the Max() outside of the iif, it is simply taking the
Maximum of the true/false values and thats why you get "" for
everything.

If the above doesnt work, you could try turning on the Totals for the
query, and setting the total function to Max on the [Current] field.

Then in another query field do:
iif([MaxOfCurrent] = [PreviousDate], " " , "")
  #10  
Old June 10th, 2009, 09:14 PM posted to microsoft.public.access
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Query Question

What action(s) are you wanting from this operation? Do you want to sort or
eliminate records?

Post your complete SQL of the query. Open in design view, click on VIEW -
SQL View, highlight all, copy, and paste in a post.

"Jennie" wrote:

Karl,

I tried to run the report with only this in the query:

Recent: IIf([Current][PreviousDate],"*","")

And I got an error message saying that the expression is not part of an
aggregate function. Did I enter it correctly? Thanks for your help.



"KARL DEWEY" wrote:

The Max as you are using it will not give you the latest date as it is not
perfoming a function on a date. It is giving you the Max of the IIF function.

"Jennie" wrote:

Karl,

I use Max because the report shows all bills ever received for every
account. I only want to see if the most current billed date matches the
PreviousDate field, not all of the bills.

"KARL DEWEY" wrote:

I do not understand your use of Max here.

Why not use it this way --
Recent: IIf([Current]=[PreviousDate], "", "")

and sort Descending?

"Jennie" wrote:

I have the following expression in my query:

Recent: Max(IIf([Current]=[PreviousDate]," ",""))

When I switch the "" and the " " it works perfectly but when I have the
Truepart set as " " all records have the "". I tried substituting " " with
another character and it works. I also tried using "" (no space) and it still
didn't work.

If you need a little background, this database tracks the 91 utility bills
we receive each month. Not all of the accounts are billed monthly, I want the
"" to appear next to the accounts that did not receive a bill for the
current period. Current is formatted as mm/yyyy and is set as month and year
of the most recent bill received for each account. PreviousDate is also
formatted as mm/yyyy and is set as the previous month and year (For example,
we receive May's bills in June, so if I were to run the report today then
PreviousDate would be 05/2009). If the two fields do not match, meaning no
bill was received in 05/2009, I want the "" to appear. If they do match,
then I don't want anything to appear. What am I doing wrong?

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:24 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.