M
Mushtaq Mohammed
Hi All,
I am trying to write an update query on a table with if-else condition. I
have the following scenario:
Column A is completely blank. Column B has some entries. What I want is
whenever there is an entry in column B set column A value as "1" and
increment each cell of column A by 1 until you hit a value in column B again.
At this point reset the counter to 0, and start putting the values in column
A from 1. For explanation please see the sample data:
Column A Column B
blank OOX
blank blank
blank OOX
blank blank
blank blank
blank OOX
The logic of my query is : Update Table X Set Column A = iif((Column
B="OOX"),1, "Column A[current index-1]+1")
I know the way of refering index in the above query is incorrect. I just
wanted to show you my logic:
After the query is run output should be somewhat like this:
Column A Column B
1 OOX
2 blank
1 OOX
2 blank
3 blank
1 OOX
Can this be done via update query? or does it have to be a macro? If so,
can you please provide a sample code for the macro? I am very new to macro
programming
I am trying to write an update query on a table with if-else condition. I
have the following scenario:
Column A is completely blank. Column B has some entries. What I want is
whenever there is an entry in column B set column A value as "1" and
increment each cell of column A by 1 until you hit a value in column B again.
At this point reset the counter to 0, and start putting the values in column
A from 1. For explanation please see the sample data:
Column A Column B
blank OOX
blank blank
blank OOX
blank blank
blank blank
blank OOX
The logic of my query is : Update Table X Set Column A = iif((Column
B="OOX"),1, "Column A[current index-1]+1")
I know the way of refering index in the above query is incorrect. I just
wanted to show you my logic:
After the query is run output should be somewhat like this:
Column A Column B
1 OOX
2 blank
1 OOX
2 blank
3 blank
1 OOX
Can this be done via update query? or does it have to be a macro? If so,
can you please provide a sample code for the macro? I am very new to macro
programming