V
Vladimír Cvajniga
#1) Cond
In old PC FAND, which was base on Pascal, we had the following:
SomeValue:=cond(SomeField=1 And OtherField="A": "Excelent",
SomeField=2 And OtherField="A": "Almost
excelent",
SomeField=3: "Hmmm...",
else: "Ooops")
Is there an equivalent in Access 2007?
IMO:
1) Select Case will not do that.
2) Select Case can't be used in computed fields.
3) With IIf it's quite complicated.
4) The easiest way: Public Function. But do I really want a function only
for one field?... :-/
———————————————————————————————————————
#2) In (PC FAND again)
SomeValue:=cond(SomeField in (1..34, 37, 50..59, 99): "Baltimore",
SomeField in (35, 36, 60): "New York",
SomeField in (100..199): "Los Angeles",
else: "Praha")
Note that there are intervals, ie. 1 to 34, 50 to 59, 100 to 199.
Is there an equivalent in Access2007?
A2002: The only function I was able to create doesn't handle intervals:
Public Function fncIn(varValue As Variant, ParamArray arrArray()) As Boolean
Dim u As Integer
For u = LBound(arrArray) To UBound(arrArray)
fncIn = varValue = arrArray(u)
If fncIn Then Exit Function
Next u
End Function
-----------------------------------------------------------------------------
Example:
dim bExist as Boolean
bExist = fncIn(SomeValue, 1, 2, 3, 8, 50)
or
bExist = fncIn(SomeValue, "17", "32", "50")
or
bExist = fncIn(SomeValue, Value1, Value2, Value3, Value4, Value5,
Value6)
-----------------------------------------------------------------------------
As to intervals:
1) Am I doing something wrong?
2) Do I need to study Access arrays? ;-)
TIA
Vlado
In old PC FAND, which was base on Pascal, we had the following:
SomeValue:=cond(SomeField=1 And OtherField="A": "Excelent",
SomeField=2 And OtherField="A": "Almost
excelent",
SomeField=3: "Hmmm...",
else: "Ooops")
Is there an equivalent in Access 2007?
IMO:
1) Select Case will not do that.
2) Select Case can't be used in computed fields.
3) With IIf it's quite complicated.
4) The easiest way: Public Function. But do I really want a function only
for one field?... :-/
———————————————————————————————————————
#2) In (PC FAND again)
SomeValue:=cond(SomeField in (1..34, 37, 50..59, 99): "Baltimore",
SomeField in (35, 36, 60): "New York",
SomeField in (100..199): "Los Angeles",
else: "Praha")
Note that there are intervals, ie. 1 to 34, 50 to 59, 100 to 199.
Is there an equivalent in Access2007?
A2002: The only function I was able to create doesn't handle intervals:
Public Function fncIn(varValue As Variant, ParamArray arrArray()) As Boolean
Dim u As Integer
For u = LBound(arrArray) To UBound(arrArray)
fncIn = varValue = arrArray(u)
If fncIn Then Exit Function
Next u
End Function
-----------------------------------------------------------------------------
Example:
dim bExist as Boolean
bExist = fncIn(SomeValue, 1, 2, 3, 8, 50)
or
bExist = fncIn(SomeValue, "17", "32", "50")
or
bExist = fncIn(SomeValue, Value1, Value2, Value3, Value4, Value5,
Value6)
-----------------------------------------------------------------------------
As to intervals:
1) Am I doing something wrong?
2) Do I need to study Access arrays? ;-)
TIA
Vlado