473,486 Members | 2,131 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VBA Code for Is Not

Hello,

I'm trying to add some data validation to the BeforeUpdate event of a
form. I want the user to select a number between 1 and 3 for the
[Choice] field. Can I use something like IsNot? Sorry, a little
rusty here!

Thanks

=====================

Private Sub Form_BeforeUpdate(Cancel As Integer)
'Data validation to ensure a choice number between 1 and 3 is
selected.
If IsNot (Me.Choice (>=1 And <=3) Then
MsgBox "Please select a choice number between 1 and 3.."
DoCmd.CancelEvent
Me.Choice.SetFocus
End If
Mar 14 '08 #1
4 1650

"WPW07" <ww********@gmail.comwrote in message
news:54**********************************@8g2000hs e.googlegroups.com...
Hello,

I'm trying to add some data validation to the BeforeUpdate event of a
form. I want the user to select a number between 1 and 3 for the
[Choice] field. Can I use something like IsNot? Sorry, a little
rusty here!

Thanks

=====================

Private Sub Form_BeforeUpdate(Cancel As Integer)
'Data validation to ensure a choice number between 1 and 3 is
selected.
If IsNot (Me.Choice (>=1 And <=3) Then
MsgBox "Please select a choice number between 1 and 3.."
DoCmd.CancelEvent
Me.Choice.SetFocus
End If

Replace IsNot with Not

iif(not (True),"Not False","Not True")
Mar 14 '08 #2
On Mar 14, 3:39*pm, "paii, Ron" <n...@no.comwrote:
"WPW07" <wwisnie...@gmail.comwrote in message

news:54**********************************@8g2000hs e.googlegroups.com...


Hello,
I'm trying to add some data validation to the BeforeUpdate event of a
form. *I want the user to select a number between 1 and 3 for the
[Choice] field. * Can I use something like IsNot? *Sorry, a little
rusty here!
Thanks
=====================
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Data validation to ensure a choice number between 1 and 3 is
selected.
* If IsNot (Me.Choice (>=1 And <=3) Then
* * * * *MsgBox "Please select a choice number between 1 and 3..."
* * * * *DoCmd.CancelEvent
* * * * *Me.Choice.SetFocus
*End If

Replace IsNot with Not

*iif(not (True),"Not False","Not True")- Hide quoted text -

- Show quoted text -
Why not use Me.Choice as a combo Box. Make it so that you cant type
anything there in KeyPress method : AcsiiCode = 0. And have the
options available obviosly having a default option.

- GL
Mar 14 '08 #3
On Mar 14, 3:49 pm, Guillermo_Lopez <g.lo...@iesdr.comwrote:
On Mar 14, 3:39 pm, "paii, Ron" <n...@no.comwrote:
"WPW07" <wwisnie...@gmail.comwrote in message
news:54**********************************@8g2000hs e.googlegroups.com...
Hello,
I'm trying to add some data validation to the BeforeUpdate event of a
form. I want the user to select a number between 1 and 3 for the
[Choice] field. Can I use something like IsNot? Sorry, a little
rusty here!
Thanks
=====================
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Data validation to ensure a choice number between 1 and 3 is
selected.
If IsNot (Me.Choice (>=1 And <=3) Then
MsgBox "Please select a choice number between 1 and 3.."
DoCmd.CancelEvent
Me.Choice.SetFocus
End If
Replace IsNot with Not
iif(not (True),"Not False","Not True")- Hide quoted text -
- Show quoted text -

Why not use Me.Choice as a combo Box. Make it so that you cant type
anything there in KeyPress method : AcsiiCode = 0. And have the
options available obviosly having a default option.

- GL
Whoa, forgot about limit to list in a combo box. I'll use that.
Thanks for your help!
Mar 14 '08 #4
WPW07 wrote:
Hello,

I'm trying to add some data validation to the BeforeUpdate event of a
form. I want the user to select a number between 1 and 3 for the
[Choice] field. Can I use something like IsNot? Sorry, a little
rusty here!

Thanks

=====================

Private Sub Form_BeforeUpdate(Cancel As Integer)
'Data validation to ensure a choice number between 1 and 3 is
selected.
If IsNot (Me.Choice (>=1 And <=3) Then
MsgBox "Please select a choice number between 1 and 3.."
DoCmd.CancelEvent
Me.Choice.SetFocus
End If
Not that I know off.
If (Me.Choice <1 Or Me.Choice >3) then
or
If Instr("123",Me.Choice) = 0 then
would work.

BTW, most folks would use
Cancel = True
instead of
DoCmd.CancelEvent

Naike
http://www.youtube.com/watch?v=0VmhcBbfsp0
Mar 14 '08 #5

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

Similar topics

51
5199
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
9
3842
by: bigoxygen | last post by:
Hi. I'm using a 3 tier FrontController Design for my web application right now. The problem is that I'm finding to have to duplicate a lot of code for similar functions; for example, listing...
4
2414
by: jason | last post by:
Hello. Newbie on SQL and suffering through this. I have two tables created as such: drop table table1; go drop table table2; go
16
3083
by: Dario de Judicibus | last post by:
I'm getting crazy. Look at this code: #include <string.h> #include <stdio.h> #include <iostream.h> using namespace std ; char ini_code = {0xFF, 0xFE} ; char line_sep = {0x20, 0x28} ;
109
5738
by: Andrew Thompson | last post by:
It seems most people get there JS off web sites, which is entirely logical. But it is also a great pity since most of that code is of such poor quality. I was looking through the JS FAQ for any...
5
4033
by: ED | last post by:
I currently have vba code that ranks employees based on their average job time ordered by their region, zone, and job code. I currently have vba code that will cycle through a query and ranks each...
0
2074
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
18
3136
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My...
37
5912
by: Alan Silver | last post by:
Hello, Newbie here, so please forgive what is probably a basic question ... I see a lot of discussion about "code behind", which if I have understood correctly, means that the script code goes...
171
7579
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
0
7100
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
6964
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
7175
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
7330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5434
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,...
1
4865
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...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.