Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Select Case - "Invalid use of Null" Problem

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Select Case - "Invalid use of Null" Problem
Lana 30.09.2006 09:14:01
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
Re: Select Case - "Invalid use of Null" Problem
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> 30.09.2006 10:51:45
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
http://I.Am/DougSteele
(no private e-mails, please)


"Lana" <Lana[ at ]discussions.microsoft.com> wrote in message
news:2AFCF971-52EB-4883-B1FF-31731F2C31C1[ at ]microsoft.com...
[Quoted Text]
> 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


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net