X
xz
I've had this lingering question for a while and am now finally trying
to address it. We know switch statements' sizes are limited. I have
this switch statement below, and I need to add more but am bumping up
against the size limitation:
SELECT Switch(
[TCODE]="4030","Purchase - abcd" ,
[TCODE]="3021","Dividend - abcd",
[TCODE]="8081","FIFO Sale - Subtract CDSC",
[TCODE]="7011" And IsNull([TBL1.SACCTNUM])<>True,"Not purchase",
[TCODE]="7011" And IsNull([TBL1.SACCTNUM])=True,"Purchase",
[TCODE]="7512" And IsNull([TBL1.SACCTNUM])<>True,"No Sale ",
[TCODE]="7512" And IsNull([TBL1.SACCTNUM])=True,"FIFO Sale",
[TCODE]="6011" And IsNull([TBL1.SACCTNUM])<>True,"Not purchase",
[TCODE]="6011" And IsNull([TBL1.SACCTNUM])=True,"Purch",
[TCODE]="6512" And IsNull([TBL1.SACCTNUM])<>True,"No sale",
[TCODE]="6512" And IsNull([TBL1.SACCTNUM])=True,"FIFO sale",
[TCODE]="7551","FIFO Sale - unmatched xchange",
[TCODE]= "6600","FIFO Sale by xyz",
[TCODE]="1010","FIFO pos adjust")
FROM TBL1;
It was suggested to me to try a lookup table, and I have done that and
populated it. It looks like this:
ID - autonumber
TCODE - Text
DESC - Text
NoSACCTNUM - Yes / No
Now I'm trying to figure out the mechanics of pulling that DESC field
into my query with a condition that sometimes the TCODE's are the
same, and the correct DESC (description) is determined by checking if
the SACCTNUM field from the main query has a value - if so, I want to
grab the DESC where NoSACCTNUM is yes. Otherwise, I want to grab the
DESC where NoSACCTNUM is no. I can change NoSACCTNUM to a text field,
I don't mind - whatever anyone suggests. I am just wondering how to
do the above logic, when I'm not a VBA expert. In Oracle I would
create a function, but I'm not clear in Access how to do this. I've
thought of doing it at the Join level, but I'm not sure that will work
either.
Thanks for any help!
JJ
to address it. We know switch statements' sizes are limited. I have
this switch statement below, and I need to add more but am bumping up
against the size limitation:
SELECT Switch(
[TCODE]="4030","Purchase - abcd" ,
[TCODE]="3021","Dividend - abcd",
[TCODE]="8081","FIFO Sale - Subtract CDSC",
[TCODE]="7011" And IsNull([TBL1.SACCTNUM])<>True,"Not purchase",
[TCODE]="7011" And IsNull([TBL1.SACCTNUM])=True,"Purchase",
[TCODE]="7512" And IsNull([TBL1.SACCTNUM])<>True,"No Sale ",
[TCODE]="7512" And IsNull([TBL1.SACCTNUM])=True,"FIFO Sale",
[TCODE]="6011" And IsNull([TBL1.SACCTNUM])<>True,"Not purchase",
[TCODE]="6011" And IsNull([TBL1.SACCTNUM])=True,"Purch",
[TCODE]="6512" And IsNull([TBL1.SACCTNUM])<>True,"No sale",
[TCODE]="6512" And IsNull([TBL1.SACCTNUM])=True,"FIFO sale",
[TCODE]="7551","FIFO Sale - unmatched xchange",
[TCODE]= "6600","FIFO Sale by xyz",
[TCODE]="1010","FIFO pos adjust")
FROM TBL1;
It was suggested to me to try a lookup table, and I have done that and
populated it. It looks like this:
ID - autonumber
TCODE - Text
DESC - Text
NoSACCTNUM - Yes / No
Now I'm trying to figure out the mechanics of pulling that DESC field
into my query with a condition that sometimes the TCODE's are the
same, and the correct DESC (description) is determined by checking if
the SACCTNUM field from the main query has a value - if so, I want to
grab the DESC where NoSACCTNUM is yes. Otherwise, I want to grab the
DESC where NoSACCTNUM is no. I can change NoSACCTNUM to a text field,
I don't mind - whatever anyone suggests. I am just wondering how to
do the above logic, when I'm not a VBA expert. In Oracle I would
create a function, but I'm not clear in Access how to do this. I've
thought of doing it at the Join level, but I'm not sure that will work
either.
Thanks for any help!
JJ