473,405 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Is this valid syntax (A97 VBA)?

MLH
380 If Not IsNull(Me!MatlsList) And (Me!MatlsCost = 0 Or
IsNull(Me!MatlsCost)) Then
390 MyMsg = "You entered something in the field entitled
'Materials List' but no charges in the 'Materials' cost field. "
400 MyMsg = MyMsg & "You must enter the amount of the charges in
the field provided or leave the description empty."
410 MsgBox MyMsg, 32, "Amount Required - " & MyApp$ & ", rev. " &
MY_VERSION$
420 Exit Sub
430 End If

Its the IF statement I'm talking about. I've never done an
If This And (This or That)
before and was just wondering if it was permissable.
Nov 13 '05 #1
7 1189
MLH <CR**@NorthState.net> wrote in
news:jk********************************@4ax.com:
380 If Not IsNull(Me!MatlsList) And (Me!MatlsCost = 0 Or
IsNull(Me!MatlsCost)) Then
390 MyMsg = "You entered something in the field entitled
'Materials List' but no charges in the 'Materials' cost field.
" 400 MyMsg = MyMsg & "You must enter the amount of the
charges in the field provided or leave the description empty."
410 MsgBox MyMsg, 32, "Amount Required - " & MyApp$ & ",
rev. " & MY_VERSION$
420 Exit Sub
430 End If

Its the IF statement I'm talking about. I've never done an
If This And (This or That)
before and was just wondering if it was permissable.

Yes, just pay attention to parentheses.

IF (NOT isnull(Me!MatlsList)) AND (Me!MatlsCost = 0 OR
isnull(Me!MatlsCost))

But you can use the NZ function very effectively here to replace
your ORed statements with nz(me!MatlsCost,0) = 0

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #2
MLH
Thx, Bob Quintal. I appreciate the note on the addn't set
of paren's. I'll test the Nz(Me!MatlsCost,0) = 0 later. Is it
true that if MatlsCost = zero OR is null, that Nz(Me!MatlsCost,0)
will = zero?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx
Yes, just pay attention to parentheses.

IF (NOT isnull(Me!MatlsList)) AND (Me!MatlsCost = 0 OR
isnull(Me!MatlsCost))

But you can use the NZ function very effectively here to replace
your ORed statements with nz(me!MatlsCost,0) = 0


Nov 13 '05 #3

"MLH" <CR**@NorthState.net> schreef in bericht news:jp********************************@4ax.com...
I'll test the Nz(Me!MatlsCost,0) = 0 later. Is it
true that if MatlsCost = zero OR is null, that Nz(Me!MatlsCost,0)
will = zero?


I believe we did have a recent and extensive thread on NZ ;-)
I believe it was started by ... hmm..., who was that guy?

Remembers me of a song:
"If you don't know this by now, you will never never never know this ...."

Arno R
Nov 13 '05 #4
MLH <CR**@NorthState.net> wrote in
news:jp********************************@4ax.com:
Thx, Bob Quintal. I appreciate the note on the addn't set
of paren's. I'll test the Nz(Me!MatlsCost,0) = 0 later. Is it
true that if MatlsCost = zero OR is null, that
Nz(Me!MatlsCost,0) will = zero?


RTFM.

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #5
Bob Quintal <rq******@sympatico.ca> wrote in
news:Xn**********************@207.35.177.135:
IF (NOT isnull(Me!MatlsList)) AND (Me!MatlsCost = 0 OR
isnull(Me!MatlsCost))


I'd not bother with the outer parens, but I'd add a pair of inner
parens:

IF (NOT isnull(Me!MatlsList)) AND ((Me!MatlsCost = 0) OR
isnull(Me!MatlsCost))

The reason is to make clear that (Me!MatlsCost = 0) is a single
expression being evaluated. I always feel it's important to surround
any comparison like that (= or < or > or <> or >= or <=) with parens
to make sure that the right thing is getting evaluated. Keep in mind
that this interpretation:

IF (NOT isnull(Me!MatlsList)) AND (Me!MatlsCost = (0 OR
isnull(Me!MatlsCost)))

would actually be valid, though it's nonsensical, and it forces an
evaluation that is the opposite of the default interpretation.

But, again, I don't believe in depending on default behaviors in
VBA, or in any implicit type coerction (which I think is related).
It may very well be reliable, but it's not good to depend on things
happening the way you expect them to when you can actually *force*
them to make them behave the way you want them to.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #6
rkc
Bob Quintal wrote:
MLH <CR**@NorthState.net> wrote in
news:jp********************************@4ax.com:

Thx, Bob Quintal. I appreciate the note on the addn't set
of paren's. I'll test the Nz(Me!MatlsCost,0) = 0 later. Is it
true that if MatlsCost = zero OR is null, that
Nz(Me!MatlsCost,0) will = zero?

RTFM.


Or better yet, RTFM and then WRITE A FREAKING TEST!
Nov 13 '05 #7
MLH
Not a bad point.
Nov 15 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Keith | last post by:
A97, NT4. I have a form with a command button which opens a second form. What's the syntax to make the second form have the same record source as the first but without hard-coding the form's...
2
by: MLH | last post by:
A97 allows separate procedures in a form module to share common label names. Access 2.0 would puke when that happened. For instance, if I had 2 procedures in an Access 2.0 form module with labels...
9
by: MLH | last post by:
Running the following code produces NO error, but renders my keyboard incapable of typing. I can use the mouse to open the class module & look at it. But if I try to type in it - nothing happens....
12
by: MLH | last post by:
Have had a runtime installation up for 4 months. Upgraded today with new ver 0.07 from 0.06. On launch, error reported... Err in fn Initialize, module AutoExec, function isnt available in query...
18
by: MLH | last post by:
I have an A97 app that automatically sends eMail using OutLook Express. Each installation requires the user to reconfigure Outlook Express to avoid prompts waiting for them to authorize or deny...
1
by: MLH | last post by:
I was wondering if Access 2003 would open and run A97 mde's and if there were any incompatibilities between VBA code in A97 that I should be aware of before distributing A97 apps to persons...
11
by: MLH | last post by:
Private Sub ButtonP_Click() On Error GoTo Err_ButtonP_Click Dim ThisForm As String ThisForm = Me.Name Exit_ButtonP_Click: Exit Sub Err_ButtonP_Click: Dim r As String, k As String, Message3...
4
by: MLH | last post by:
I copied the code example below from A97 HELP. However, I get an error when I try to use something like frmMainMenu.Hide and am uncertain as to why. Ideas? The following example assumes two...
1
by: MLH | last post by:
I have an A97 application with a form (frmEditOwners). Here's a code snippet for deleting current record... Private Sub DelOwnerRecBtn_Click() On Error GoTo Err_btnCloseOwnerEditForm_Click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.