W
Webtechie
Hello,
I need to create a select case in VBA and I'm not sure how.
The table is myTable
ID NAME PAYMENT SAVINGS CHECKING CREDITCARD
1 John Smith DB x
If savings is not null, then place a "DB" in payment. If checking is not
null, then place a "DB" in payment. If CreditCard is not null, then place
"CD" in payment.
I would think this would work:
DIM strSQL as string
strSQL = "Select ID, NAME, Payment = " _
& "case " _
& "when len(savings) > 0 then """DB""" _
& "when len(checking) > 0 then """DB""" _
& "when len(creditcard) > 0 then """CD"""
& " from myTemp"
docmd.runSQL strSQL
I'm seeing in the forums that the above query won't work. How do you write
something like this in ACCESS SQL/VBA?
Thanks.
Tony
I need to create a select case in VBA and I'm not sure how.
The table is myTable
ID NAME PAYMENT SAVINGS CHECKING CREDITCARD
1 John Smith DB x
If savings is not null, then place a "DB" in payment. If checking is not
null, then place a "DB" in payment. If CreditCard is not null, then place
"CD" in payment.
I would think this would work:
DIM strSQL as string
strSQL = "Select ID, NAME, Payment = " _
& "case " _
& "when len(savings) > 0 then """DB""" _
& "when len(checking) > 0 then """DB""" _
& "when len(creditcard) > 0 then """CD"""
& " from myTemp"
docmd.runSQL strSQL
I'm seeing in the forums that the above query won't work. How do you write
something like this in ACCESS SQL/VBA?
Thanks.
Tony