PDA

View Full Version : [SOLVED] Need Assistance with a complex If And Then statement



Poundland
10-29-2015, 09:43 AM
Hi Guys,

Once again I call on your collective wisdom to assist me on a coding issue,

I will not go into the full details, but I am trying to construct a code line, current code is below;


If Whoff > allo And Whoff >= rsstoreconday And rsconf_time <= "16:00" Then

I have another variable to add into the mix, Cycday.

My dilemma is this;

Whoff will always be a value between 1 and 7, allo will always be a value between 1 and 7, rsstoreconday will always be a value between 1 and 7 and rsconf_time will be a time value between 06:00 to 22:00, the variable I want to add will always be a value between 1 and 17.

I want to construct the code line as above but by adding in the variable Cycday, but to make the argument True if Cycday is greater than 7.

If the code line returns a False argument then the routine adds 1 to the Cycday variable.

I will attach the documents for you to check through, all the code lines work with the exception of the above which always returns a false argument which should otherwise be true if the Cycday variable was considered.

I hope I have made sense...

Thanking you in advance for your help.

P.S. The Master Copy would be a much larger document with over 600 records but to simplify I have reduced to 2 records.

Poundland
10-30-2015, 06:02 AM
I have since tried using an ElseIf statement but still cannot get it to work correctly;

I have changed the time variable to a number.


If Whoff > allo And Whoff = rsstoreconday And rsconf_time > "0.7" And cycday > 7 Then
ElseIf Whoff > allo And Whoff = rsstoreconday And rsconf_time <= "0.7" Then

Tommy
10-30-2015, 09:14 AM
I didn't test, but I think this is what you want.


If (Whoff > allo And Whoff >= rsstoreconday And rsconf_time <= "16:00") OR Cycday > 7 Then

Else
Cycday =Cycday+1
endif

Poundland
10-30-2015, 09:41 AM
Tommy,

Thank you for your response, this appears to have done the trick.

I assume that the code line is checking to see if the statement inside the Brackets is True or False, if False then it checks the Or statement Line and if that is True then it performs the next code line rather than skipping to the End If, is this correct?

Tommy
10-30-2015, 10:20 AM
It is checking if either is true, if the first part is true it does not check the second part. If both parts are false then it executes the else statements.

Aussiebear
10-30-2015, 03:59 PM
I want to construct the code line as above but by adding in the variable Cycday, but to make the argument True if Cycday is greater than 7.

If the code line returns a False argument then the routine adds 1 to the Cycday variable.

Just wondering if, given the logic of your statements in Post #1 whether we test the value of Cycday first to make the code quicker?



If Cycday >7 or Whoff > all And Whoff = rsstoreconday And rsconf_time > "0.7"
Else
Cycday = Cycday +1
End If

Poundland
11-02-2015, 02:47 AM
Aussie,

Thank you for your comment, I will check it out..