if formula with a few conditions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to make 2 different iif formulas, 1 with 3 conditions and 1 with at
least 7.

It is for a student application database for a college,
the first formula i want to be like this:

the students have to enclose a passport photo and 30 pound deposit. So the
letter sent out to them should be that if they haven't given any it should
say, "please enclose a passport photo and 30 deposit." If they've just given
deposit, it should say "please enclose a passport photo" and if they've just
given a passport photo it should say "please enclose 30 deposit"

The passport photo and 30 pound deposit fields are both yes/no boxes

The second formula is for the college acceptance and refusal form. There are
a few different reasons why some students are refused eg. too young, no room
etc and a few reasons why accepted. So depending on their status they get a
letter with the reply to their application.

I began making buttons on the form to show acceptance letter for the current
student id on screen and i thought that i'll have all the different possible
letters as buttons on the form and the secretary will click the correct one.
But it would be much better if i could have a formula something like:

iif status id is acc then preview report 1a for current id and iif status id
is refty then preview report 2b etc etc with about 8 different possibilities.
Is that possible?
Thank You!
 
Basically, on the onclick event of the report button, determine whether the
application is valid or not and open either the invalid report or the
appropriate acceptance/rejection report accordingly. And you could do it more
elegantly than this - this is just an example.

Private Sub Cmd_Button_Click()
Dim strDocName As String

If Me!Photo = False Or Me!Paid = False Then
strDocName = "Rpt_Application_Invalid"
GoTo OpenRep
End If

If Me!Status = "OK" Then
strDocName = "Rpt_Application_Approved"
Else
strDocName = "Rpt_Application_Rejected"
End If

OpenRep:
DoCmd.OpenReport strDocName, acViewPreview

End Sub


In the query for the invalid report, you want:
Reject_Reason : Iif(NoDeposit = true, iif(NoPhoto = true, "Please enclose
£30 and a photograph", "Please enclose £30"),iif(NoPhoto = true, "Please
enclose a photograph", "You have enclosed a photograph and £30")))

.....obviously if these are the only reasons you would reject an application,
you wouldn't expect the last case to occur.

in the query for Rpt_Application_Rejected, you want to do a similar thing to
the Rpt_Invalid one to indicate the specific reason it was rejected.

Hope this helps.
 
Actually, come to think about it, for the second report, you're better off
NOT using an IIF formula. If you've got 7 options, it will get unwieldy.

Instead, on the On_Format event of the Detail part of your report, make your
selection there.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
dim strMessage as string
strMessage = "Your application has been rejected for the following
reason(s):"

if me!Age < 20 then
strMessage = strMessage & chr(13) & "You are below the minimum
application age".
end if

if me!NoRooms = True then
strMessage = strMessage & chr(13) & "No rooms were available."
end if

'and so on....

me!Explanation = strMessage


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top