Kerney said:
Hi Chris2,
I'm soory if my description was not specific enough. I have a transactions
database with over 110,000 transactions. Within each transaction, the
payment can come from one or a combination of ten vendors. In some cases, we
can get ten different payments from different field offices of the same
vendor. I am trying to isolate these transactions by having a formula in a
new field that indicates if all payments are coming from one company (many
different field offices or from several different companies.
As I stated before, I tried a nested IIF statement but there are too many
variables.
Any suggestions assuming I explained myself better this time?
Thanks,
Kerney,
I can't tell from this request whether you have the properly
structured table I was thinking you do, or not.
Two other posters have already stated you may have repeating columns
for the same data based on the description of your original post.
The above text doesn't say one way or another.
If you have multiple columns for VendorName, then all bets are off.
I can't think of an offhand way to do it in those circumstances, and
you have now encountered the "reason" relational databases aren't
designed that way (it makes some queries difficult to impossible).
It would require, I think, at a minimum, a giant set of conditions.
I'm not sure if this will exceed any internal limits of the function,
either.
IIF(
(VendorName1 = VendorName2 AND
VendorName1 = VendorName3 AND
VendorName1 = VendorName4 AND
VendorName1 = VendorName5 AND
VendorName1 = VendorName6 AND
VendorName1 = VendorName7 AND
VendorName1 = VendorName8 AND
VendorName1 = VendorName9 AND
VendorName1 = VendorName10) AND
(VendorName2 = VendorName3 AND
VendorName2 = VendorName4 AND
VendorName2 = VendorName5 AND
VendorName2 = VendorName6 AND
VendorName2 = VendorName7 AND
VendorName2 = VendorName8 AND
VendorName2 = VendorName9 AND
VendorName2 = VendorName10) AND
..
..
..
(VendorName8 = VendorName9 AND
VendorName8 = VendorName10) AND
(VendorName9 = VendorName10), 1, 2)
If the internal limits of the function aren't exceeded, that *might*
work.
Or, you could write a VBA function:
Public Function VendorNameDups(TransactionID AS Long) AS Byte
<code to grab the VendorNames out of a particular row
and find out if they're all the same, probably by
loading them into an array and running them through
a recursive loop of some sort>
VendorNameDups = FinalDecision 'Value will be 1 or 2
End Function
This function could make the decision in place of a while IIF
statement stuck in the middle of a QueryDef.
In the end, the VBA function will probably be more useful.
Sincerely,
Chris O.