Hello all,
You may have seen my previous post around Union queries, and I've just thought of a MUCH better way of doing it. To provide some context about what I'm currently doing;
I currently have a Database where I am comparing the 'Start' value and 'End' value of Servers. In order to do this I have to seperate each server into it's own Query then perform FIRST and LAST functions to compare the values, this results in 3 queries per Server. Query 1; This provides the Server data and name and calculates the Free space from the Total/Used and converts the numbers into GB (rather than KB - don't ask!). It also works the 'Date Diff' from a Form which the user will select the start date and end date from. Query 2; This provides the comparison between the FIRST used/Total/Free etc against the LAST used/Total/Free etc giving a comparison of data between the dates. Query 3; This then calculates the Daily Growth of the Server and works out how long it would take for it to run out of space. I.E. The Used Difference figure divided by the Date Difference figure. This will sometimes throw up a '0' if, for example, the numbers are the same. The next problem comes when trying to get the 'Time Left' as it has to divide the 'Free Space' by the 'Daily Growth' but obviously you can't divide something by 0!! So I get a big fat error .... Which is fine!!
Now... I want to shove all of this into a pretty report, so it would be very beneficial to have it all in the same SubReport; meaning I need to use the UNION function! Hooooowever! You can't use UNION when you have an error ... Now you see my problem!!?
So..... Here is the proposed solution (I'd hate to just shout "HELP" without at least trying to think about it first!!) ... If I could incorporate an IF/IIF or what ever it's called in Access with a UNION function, it could work like the below...
IF DailyGrowth >0 In Query3, then Select the relevant fields and move onto the next UNION command (where it will then have another IF for the next Server Query where this data resides). Otherwise just move onto the next Server... I've had a go at trying to explain this below...
[Code]
(IF
Server1Query3.DailyGrowth >0 Then Select [Field 1] AND
(IF
Server2Query3.DailyGrowth >0 Then Select UNION [Field 1] AND
(IF
Server3Query3.DailyGrowth >0 Then Select UNION [Field 1])))
Else
IF(
Server2Query3.DailyGrowth >0 Then Select Union [Field 1] AND
(IF
Server3Query3.DailyGrowth >0 Then Select UNION [Field 1]))
ELSE
IF(Server3Query3.DailyGrowth >0 Then Select UNION [Field 1])
ELSE
DO NOTHING
make sense??