Hi
Why does the AND bit of my if statement not work?
away = 0
If rs!Stop_date < rs2!weekendings - 4 Then rs1!Mon = away and rs1!Mon = away
Hi
Why does the AND bit of my if statement not work?
away = 0
If rs!Stop_date < rs2!weekendings - 4 Then rs1!Mon = away and rs1!Mon = away
You statement makes no sense.
each assignment must be on a separate line....
if...then
rst1= away
rst1= aaway
end if
...besides...why have the same statement
Perhaps you could tell us in plain English WHAT you are trying to accomplish?
How do you know that it's not working?
Then rs1!Mon = away and rs1!Mon = away
Both parts of the Then Clause are assigning the same value to the same field! Perhaps the second 'And' part is supposed to be assigning a value to something other than the field named Mon?
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007
Yep second Mon should have been Tue.
Sorted it, many thanks.
second Mon should have been Tue.
Sorted it, many thanks.
As my signature says:
The Devil's in the Details!
Glad we could help!
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007
Sorry ... I just can't stand it any more.
This is a very poorly written statement.If rs!Stop_date < rs2!weekendings - 4 Then rs1!Mon = away and rs1!Mon = away
To have multiple statements on a line, you must separate them using a colon
This still will not update fields "Mon" and "Tue". You cannot change the value of a field in a recordset without using "rs1.Edit" & "rs1.Update".If rs!Stop_date < rs2!weekendings - 4 Then rs1!Mon = away : rs1!Mon = away
There are two forms of the IF() function: the single line and the block form.
The single line form has been depreciated: it was used back in the day when memory was expensive, processors were slow and you had to count bytes and cycles.
In VBA you should always use the block form; there is no reason not to. The block form is much easier to read.
This is the block form:
Code:Away = 0 If rs!Stop_date < rs2!weekendings - 4 Then rs1.Edit rs1!Mon = Away rs1!Tue = Away rs1.Update End If
OK, off my rant.
Having said all of that, the single line will work if you use this:
Note the colons in the line.Code:If rs!Stop_date < rs2!weekendings - 4 Then rs1.Edit: rs1!Mon = Away: rs1!Tue = Away: rs1.Update
As I said, not as easy to read/understand.......