Rat's Nest Of A Problem

May 10, 2006

I've been trying to assign tours for an upcoming conference from the three options chosen by people, based on when they chose them. Now that the first tours are starting to fill up (maximum 40), some people should get shunted to their 2nd or 3rd choices. Having a hard time figuring out how to get Access to spit out that 'remaining' top choice, though.

I tried
SELECT IIF([TourChoice1]=10 Or [TourChoice1]=11 Or [TourChoice1]=14 Or [TourChoice1]=22,[TourChoice2],[TourChoice1])
AS TopChoice, tableRegistrants.RegistrationDate, tableRegistrants.TourFinal, tableRegistrants.PaymentMade, tablePeople.City, tablePeople.State
FROM tablePeople INNER JOIN tableRegistrants ON tablePeople.PersonID = tableRegistrants.RegID
WHERE (((tableRegistrants.TourFinal) Is Null))
ORDER BY IIF([TourChoice1]=10 Or [TourChoice1]=11 Or [TourChoice1]=14 Or [TourChoice1]=22,[TourChoice2],[TourChoice1]) DESC , tableRegistrants.RegistrationDate; once I got four full tours, but then realized that it wasn't taking into account anyone whose 1st and 2nd choices were taken. There's a much larger IF statement possible here, but I'm almost certainly missing something.

Factoids: 25 tour options, 40 people max per tour, about 500 people total. They're chosen based on when they registered (early registrations get their first choice, overflow on full choices get their 2nd, etc). And no, I don't have any choice on how the registration database spits them out to me.

View Replies


ADVERTISEMENT

Nest Iif Using Instr Function

Dec 11, 2007

Hello,

I am trying to write a query that will search a field for a string until it discovers a comma. If there isn't a comma I want the field left as is. If there is a comma I want it to grab all strings before the comma and then take the string after the comma and flip the arrangement to another field..ie (flipname)

example if a field has [Smith, John] I want it displayed as John Smith

Here's is the code I was attempting to use below, it generates syntax errors!

SELECT Exercise1.name, Iif(Instr[name],",")=0,[Name], Mid([name],Instr([name]),+1,instr([name]),",")-1 as expr1
FROM Exercise1;

Thanks for your help!!!!!!

View 10 Replies View Related

Looping To Nest IIF Statements

Aug 8, 2005

There has got to be a better way to do what I want to do. Here is the situation:

I have a weekly forecast (up to 14 weeks worth) that I want to apply to the inventory that I have on hand to generate figure out how many 'days' of forecast that I have on hand. Eg. I have 7 units on hand, next week's forecast is 7 units therefore I have 7 days of inventory.

Here is how I am doing this:

SQL = "SELECT SKU, "
SQL = SQL & "IIF([ON_HAND]<=[W1 FORECAST], [OVERSTK_POT]/([W1 FORECAST]/7), "
weeks = "[W1 FORECAST]"
days = 7
end_brackets = ")"
For n = 2 To 14
weeks = weeks & "+[W" & n & " FORECAST]"
days = days + 7
end_brackets = end_brackets & ")"
SQL = SQL & "IIF([ON_HAND]<=(" & weeks & "), [ON_HAND]/((" & weeks & ")/" & days & "), "
Next n
SQL = SQL & "105" & end_brackets & " AS OVERSTOCK_DAYS, "

I have 2 issues with this code. The first is that 12 nested iif statements is all that will be allowed in this loop before the query becomes too complex. The second is that this cannot possibly be the best method to accomplish this. I'm hoping someone might know a better method.

Thanks!

View 1 Replies View Related

Syntax For Nest JOIN In MS Access?

Feb 22, 2008

This query works:

SELECT p.AcntNumber, p.Name, d.FromDate
FROM Daysheet AS d
INNER JOIN Patient AS p ON d.AcntNumber=p.AcntNumber

But this does not:

SELECT p.AcntNumber, p.Name, d.FromDate, c.CPT
FROM Daysheet AS d
INNER JOIN Patient AS p ON d.AcntNumber=p.AcntNumber
INNER JOIN Charge AS c ON c.Id=d.ChargeNum

Nor this:

SELECT p.AcntNumber, p.Name, d.FromDate, c.CPT
FROM Daysheet AS d
(INNER JOIN Patient AS p
(INNER JOIN Charge AS c ON c.Id=d.ChargeNum)
ON d.AcntNumber=p.AcntNumber)

How do you word a nested join?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved