VBA Code for Is Not 
March 14th, 2008, 07:45 PM
| | | 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 | 
March 14th, 2008, 07:45 PM
| | | Re: VBA Code for Is Not
"WPW07" <wwisnieski@gmail.comwrote in message
news:547f7eb1-f441-42bb-b104-1023dc4a9456@8g2000hse.googlegroups.com... Quote:
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") | 
March 14th, 2008, 07:55 PM
| | | Re: VBA Code for Is Not
On Mar 14, 3:39*pm, "paii, Ron" <n...@no.comwrote: Quote:
"WPW07" <wwisnie...@gmail.comwrote in message
>
news:547f7eb1-f441-42bb-b104-1023dc4a9456@8g2000hse.googlegroups.com...
>
>
>
>
>> Quote:
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!
| >>> Quote:
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 | 
March 14th, 2008, 07:55 PM
| | | Re: VBA Code for Is Not
On Mar 14, 3:49 pm, Guillermo_Lopez <g.lo...@iesdr.comwrote: Quote:
On Mar 14, 3:39 pm, "paii, Ron" <n...@no.comwrote:
>
>
> Quote: |
"WPW07" <wwisnie...@gmail.comwrote in message
| > Quote: |
news:547f7eb1-f441-42bb-b104-1023dc4a9456@8g2000hse.googlegroups.com...
| >> Quote: Quote:
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!
| | >>> Quote: Quote:
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
| | >> Quote: |
iif(not (True),"Not False","Not True")- Hide 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! | 
March 14th, 2008, 08:05 PM
| | | Re: VBA Code for Is Not
WPW07 wrote: Quote:
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 | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 220,840 network members.
|