473,386 Members | 1,773 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,386 software developers and data experts.

Before Update Event for Text Box Contents

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
4 2213
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: PAUL EDWARDS | last post by:
I have a windows form that is bound to a datatable. In VB6 I could just update the field contents and it would be updated in the database, however if I update the text property of the control from...
9
by: Pam Ammond | last post by:
I need the code to update the database when Save is clicked and a text field has changed. This should be very easy since I used Microsoft's wizards for the OleDBAdapter and OleDBConnection, and...
5
by: PAUL EDWARDS | last post by:
I have a windows form that is bound to a datatable. In VB6 I could just update the field contents and it would be updated in the database, however if I update the text property of the control from...
9
by: Jacek Jurkowski | last post by:
.... make COM exposed object to have both constructors COM visible not only the first one?
7
by: Schmidty | last post by:
Okay...I have another 'newbie' question; I have a function that loads a page and the action is $_SERVER; In the form that is in a function(method?) within a class a variable is passed back to...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.