Hi Douglas,
My fields (values, but not controls on form) sometimes have Null value.
And
I wanted to treat them separately form "0" values at first. Anyway, I
reconsidered and changed my code as to below:
Select Case True
Case ([NotPaid] = True)
stDocName = "PREQs"
Case ((Nz([CashVND], 0) > 0) And (IsNull([CW_No])))
stDocName = "Cash Received"
Case (Nz([CashVND], 0) < 0)
stDocName = "Cash Spent"
Case (Nz([BA176USD_N], 0) > 0)
stDocName = "BA-176-Received"
Case (Nz([BA351USD_N], 0) > 0)
stDocName = "BA-351-Received"
Case (Nz([BA324VND_N], 0) > 0)
stDocName = "BA-324-Received"
Case (Nz([BA305VND_N], 0) > 0)
stDocName = "BA-305-Received"
Case ((Nz([BA176USD_N], 0) < 0) And (IsNull([CW_No])))
stDocName = "BA-176-Spent"
Case ((Nz([BA351USD_N], 0) < 0) And (IsNull([CW_No])))
stDocName = "BA-351-Spent"
Case ((Nz([BA324VND_N], 0) < 0) And (IsNull([CW_No])))
stDocName = "BA-324-Spent"
Case ((Nz([BA305VND_N], 0) < 0) And (IsNull([CW_No])))
stDocName = "BA-305-Spent"
Case ((Nz([BA176USD_N], 0) < 0) And (Not IsNull([CW_No])))
stDocName = "BA-176-Withdrawal"
Case ((Nz([BA351USD_N], 0) < 0) And (Not IsNull([CW_No])))
stDocName = "BA-351-Withdrawal"
Case ((Nz([BA324VND_N], 0) < 0) And (Not IsNull([CW_No])))
stDocName = "BA-324-Withdrawal"
Case ((Nz([BA305VND_N], 0) < 0) And (Not IsNull([CW_No])))
stDocName = "BA-305-Withdrawal"
Case Else
stDocName = "blanks"
End Select
Now if all 4 [bank fields] and [CashVND] are "Null" or any of them has "0"
value my button will open the form "blanks" - which is also ok with me.
But one thing still doesnt work - the cases with "Withdrawals" such as
below:
Case ((Nz([BA176USD_N], 0) < 0) And (Not IsNull([CW_No])))
stDocName = "BA-176-Withdrawal"
I get the error statement that "The specified filed [ID] could refer to
more
than one table listed in the FROM clause of your SQL statement".
Why that happens? Something wrong with my logic in the code?
(for explanation: when [CW_No] is not Null, one of the [bank fields] will
have a negative value and the [CashVND] will have equal positive value.
And i
need to open 4 different forms depending on which of the [bank fields] is
not
Null)
Can you show me my mistake please?
Thank you.
Lana
Douglas J. Steele said:
You're looking at values for a number of different fields (or are they
controls on a form?): [NotPaid], [CashVND] and [BA176USD_N]. Are you
positive all of them have values?
To be safe, try something like:
Select Case True
Case (Nz([NotPaid], False) = True)
stDocName = "PREQs"
Case (Nz([CashVND], 0) > 0) And (IsNull([CW_No]))
stDocName = "Cash Received"
Case (Nz([CashVND], 0) <= 0)
stDocName = "Cash Spent"
Case (Nz([BA176USD_N], 0) > 0)
stDocName = "BA-176-Received"
Case Else
stDocName = "blanks"
End Select
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
Hi all,
I've got a button which is supposed to open differrent forms depending
on
some condition. I got a "Select Case" Code for it as below:
Select Case True
Case ([NotPaid] = True)
stDocName = "PREQs"
Case ([CashVND] > 0) And (IsNull([CW_No]))
stDocName = "Cash Received"
Case ([CashVND] <= 0)
stDocName = "Cash Spent"
Case ([BA176USD_N] > 0)
stDocName = "BA-176-Received"
Case Else
stDocName = "blanks"
End Select
I tested it each case one by one and it works, but when i put them
together
- it gives me the message "Invalid use of Null". What could be wrong
here?
[CW_No] is a text field, [NotPaid] is a "Y/N", the rest are numbers
(which
can have values with +/- or 0). Why it sais "Invalid use of Null"?
Please,
can anybody help?
Thank you.
Lana