If statement

melanieh

Registered User.
Local time
Today, 00:07
Joined
Nov 25, 2007
Messages
44
Just need some quick help in clearing up something....

I have a form with the follwing.......
OrderDate
default value =Date()
InvoiceDate
control source =[OrderDate]+2
DayoftheWeek
control source =Weekday([InvoiceDate])
ActualDateofInvoice
control source =IIf([Weekday]=7,[InvoiceDate]+2,[InvoiceDate])

Basically the invoice date is automatically supposed to be 2 days after the order date, but it needs to avoid Saturday and Sunday.
So.... on the DayoftheWeek field it looks at the invoice date and it returns 1, 2, 3, and so on for what day of the week it is.
Then on ActualDateofInvoice it uses an if function that if it is Saturday or day 7, add 2 days to the invoice date and put that in the field.

I want to add another if statement to the control source in ActualDateofInvoice that will also add 1 day for Sunday. Here is what I have tried: =IIf([Weekday]=7,[InvoiceDate]+2,[InvoiceDate]) Or IIf([Weekday]=1,[InvoiceDate]+1,[InvoiceDate])

For some reason the above statement gives me a -1 in all the fields. It works fine until I add the second if statement. What error am I making?
Or do I need a better way to do this?

Thanks!
 
ActualDateofInvoice
control source =IIf([Weekday]=7,[InvoiceDate]+2,[InvoiceDate])

I want to add another if statement to the control source in ActualDateofInvoice that will also add 1 day for Sunday.
Try nesting the statements so they are read as one, instead of writing a double criteria statement...
Code:
=IIf([Weekday]=7,[InvoiceDate]+2,IIf([Weekday]=1, [InvoiceDate]+1, [InvoiceDate]))
Or, you could use VB code with the OnCurrent Event, for any of the control values.
 
worked perfectly! Thanks a bunch!
 

Users who are viewing this thread

Back
Top Bottom