By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,289 Members | 1,730 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,289 IT Pros & Developers. It's quick & easy.

Before Update Event for Text Box Contents

P: n/a
I need assistance regarding how to structure code for preventing
values being entered into three text fields.

Although the two of the three text fields can have values
concurrently, it is not permitted if one of the fields has a specific
value of "S", I've tried using the following code and variations to
same on the BeforeUpdate Event on the form, but so far no go. Any
assistance to resolve this issue will be appreciated. Thanks, Dalan

If Not IsNull(Me!Display1) And Not IsNull(Me!Display2) Then
If Me!Stock = "S" Then
MsgBox "You cannot have both a Display Case and a (S) Stock
code. You must choose one or the another.", vbExclamation

Me!Stock.SetFocus
Cancel = True
End If
End If
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I believe you may want Or instead of And in the first If statement. This
would result in checking to see if Me!Stock="S" if either Display1 or
Display2 had a value. You could probably make it a single statement (note
the parenthesis):

If (Not IsNull(Me!Display1) Or Not IsNull(Me!Display2)) And Me!Stock = "S"
Then

What might be easier to read would be (and would use And instead of Or)

If Not (IsNull(Me!Display1) And IsNull(Me!Display2)) And Me!Stock = "S" Then

--
Wayne Morgan
Microsoft Access MVP
"Dalan" <ot***@safe-mail.net> wrote in message
news:50**************************@posting.google.c om...
I need assistance regarding how to structure code for preventing
values being entered into three text fields.

Although the two of the three text fields can have values
concurrently, it is not permitted if one of the fields has a specific
value of "S", I've tried using the following code and variations to
same on the BeforeUpdate Event on the form, but so far no go. Any
assistance to resolve this issue will be appreciated. Thanks, Dalan

If Not IsNull(Me!Display1) And Not IsNull(Me!Display2) Then
If Me!Stock = "S" Then
MsgBox "You cannot have both a Display Case and a (S) Stock
code. You must choose one or the another.", vbExclamation

Me!Stock.SetFocus
Cancel = True
End If
End If

Nov 12 '05 #2

P: n/a
Well, nothing seems to work whether And Or, or over a dozen different
themes of this expression. What could be wrong? Anyone's input would
be welcomed. Thanks.
"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:<EV*******************@newssvr33.news.prodigy .com>...
I believe you may want Or instead of And in the first If statement. This
would result in checking to see if Me!Stock="S" if either Display1 or
Display2 had a value. You could probably make it a single statement (note
the parenthesis):

If (Not IsNull(Me!Display1) Or Not IsNull(Me!Display2)) And Me!Stock = "S"
Then

What might be easier to read would be (and would use And instead of Or)

If Not (IsNull(Me!Display1) And IsNull(Me!Display2)) And Me!Stock = "S" Then

--
Wayne Morgan
Microsoft Access MVP
"Dalan" <ot***@safe-mail.net> wrote in message
news:50**************************@posting.google.c om...
I need assistance regarding how to structure code for preventing
values being entered into three text fields.

Although the two of the three text fields can have values
concurrently, it is not permitted if one of the fields has a specific
value of "S", I've tried using the following code and variations to
same on the BeforeUpdate Event on the form, but so far no go. Any
assistance to resolve this issue will be appreciated. Thanks, Dalan

If Not IsNull(Me!Display1) And Not IsNull(Me!Display2) Then
If Me!Stock = "S" Then
MsgBox "You cannot have both a Display Case and a (S) Stock
code. You must choose one or the another.", vbExclamation

Me!Stock.SetFocus
Cancel = True
End If
End If

Nov 12 '05 #3

P: n/a
Ok, then I'll need a better explanation of "doesn't work". What is it doing,
not doing, and is supposed to do?

--
Wayne Morgan
MS Access MVP
"Dalan" <ot***@safe-mail.net> wrote in message
news:50**************************@posting.google.c om...
Well, nothing seems to work whether And Or, or over a dozen different
themes of this expression. What could be wrong? Anyone's input would
be welcomed. Thanks.

Nov 12 '05 #4

P: n/a
Dalan wrote:
I need assistance regarding how to structure code for preventing
values being entered into three text fields.

Is the Enter event of these controls suitable for this?

--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.