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

IF Less Than (<) not working in VB Code - Access 2000

Hello'

I am attempting to provide validation for a field on a form through a
command.
(the validation is only part of the command). The field is a text box
formatted as a fixed number...

Basically I want the resulting value to only be allowed to be between
2 & 8.

The code works fine for the greater than (>) but for some reason does
not work for less than(<) ??
abbreviated code snippet:

If Me.Field "2" And Me.Field < "8" Then
Me.cmdSave.Visible = True
MsgBox ("Good")
Else
MsgBox ("Bad")
If Me.cmdSave.Visible = True Then
Me.cmdSave.Visible = False
End If
End If

I even went as far as to leave out the AND portion of the statement &
only put in the 1 criteria (less than 8) & vice versa. Also used the
(.Value) qualifier for the field.

The greater than 2 criteria works everytime (whether after the less
than AND) portion of the line or before it, or on it's own with no AND
statement.

But the less than # will NOT work???

Any ideas why?
Oct 3 '08 #1
6 5996
ry***********@gmail.com wrote:
Hello'

I am attempting to provide validation for a field on a form through a
command.
(the validation is only part of the command). The field is a text box
formatted as a fixed number...

Basically I want the resulting value to only be allowed to be between
2 & 8.

The code works fine for the greater than (>) but for some reason does
not work for less than(<) ??
abbreviated code snippet:

If Me.Field "2" And Me.Field < "8" Then
Me.cmdSave.Visible = True
MsgBox ("Good")
Else
MsgBox ("Bad")
If Me.cmdSave.Visible = True Then
Me.cmdSave.Visible = False
End If
End If

I even went as far as to leave out the AND portion of the statement &
only put in the 1 criteria (less than 8) & vice versa. Also used the
(.Value) qualifier for the field.

The greater than 2 criteria works everytime (whether after the less
than AND) portion of the line or before it, or on it's own with no AND
statement.

But the less than # will NOT work???

Any ideas why?
Hmmm...do you only permit numbers from 3 to 7? If not, maybe use >= and <=.
Oct 3 '08 #2
Hmmm...do you only permit numbers from 3 to 7? *If not, maybe use >= and <=.
With or without the (=)'s I still get the same issue.

If the field ends up being less than (<) the lower value then the code
works fine...i.e Error message.
If the field ends up being greater (>) the higher value then the code
does not work... i.e. NO error message.

It's like Access is ignoring the greater than symbol???

Oct 3 '08 #3
sry... the Less than < symbol is being ignored by access...
Oct 3 '08 #4

"ry***********@gmail.com" <Ry***********@gmail.comwrote in message
news:d4**********************************@i76g2000 hsf.googlegroups.com...
Hello'

I am attempting to provide validation for a field on a form through a
command.
(the validation is only part of the command). The field is a text box
formatted as a fixed number...

Basically I want the resulting value to only be allowed to be between
2 & 8.

The code works fine for the greater than (>) but for some reason does
not work for less than(<) ??
abbreviated code snippet:

If Me.Field "2" And Me.Field < "8" Then
Me.cmdSave.Visible = True
MsgBox ("Good")
Else
MsgBox ("Bad")
If Me.cmdSave.Visible = True Then
Me.cmdSave.Visible = False
End If
End If

I even went as far as to leave out the AND portion of the statement &
only put in the 1 criteria (less than 8) & vice versa. Also used the
(.Value) qualifier for the field.

The greater than 2 criteria works everytime (whether after the less
than AND) portion of the line or before it, or on it's own with no AND
statement.

But the less than # will NOT work???

Any ideas why?
Can the value of Me.Field be greater then 9? A text compare of "10" < "8"
is true.

Try If cint(Me![Field]) 2 And cint(Me![Field]) < 8 Then

Oct 3 '08 #5
On Oct 3, 2:32*pm, "paii, Ron" <n...@no.comwrote:
"ryan.paque...@gmail.com" <Ryan.Paque...@gmail.comwrote in message

news:d4**********************************@i76g2000 hsf.googlegroups.com...


Hello'
I am attempting to provide validation for a field on a form through a
command.
(the validation is only part of the command). The field is a text box
formatted as a fixed number...
Basically I want the resulting value to only be allowed to be between
2 & 8.
The code works fine for the greater than (>) but for some reason does
not work for less than(<) ??
abbreviated code snippet:
* * If Me.Field "2" And Me.Field < "8" Then
* * * * * *Me.cmdSave.Visible = True
* * * * * *MsgBox ("Good")
* * * Else
* * * * * MsgBox ("Bad")
* * * * * * * * If Me.cmdSave.Visible = True Then
* * * * * * * * * * Me.cmdSave.Visible = False
* * * * * * * * End If
* * End If
I even went as far as to leave out the AND portion of the statement &
only put in the 1 criteria (less than 8) & vice versa. Also used the
(.Value) qualifier for the field.
The greater than 2 criteria works everytime (whether after the less
than AND) portion of the line or before it, or on it's own with no AND
statement.
But the less than # will NOT work???
Any ideas why?

Can the value of Me.Field be greater then 9? A text compare of *"10" < "8"
is true.

Try * If cint(Me![Field]) 2 And cint(Me![Field]) < 8 Then- Hide quoted text -

- Show quoted text -
You are the Man Ron!!!
That works!
So when an integer is in text field & I want to validate it based on
the Integer value, then I need to use the Cint function.
I got it committed to memory now! thank goodness for google groups...
Oct 3 '08 #6
"ry***********@gmail.com" <Ry***********@gmail.comwrote in message
news:b0**********************************@t54g2000 hsg.googlegroups.com...
On Oct 3, 2:32 pm, "paii, Ron" <n...@no.comwrote:
"ryan.paque...@gmail.com" <Ryan.Paque...@gmail.comwrote in message

news:d4**********************************@i76g2000 hsf.googlegroups.com...
>So when an integer is in text field & I want to validate it based on
the Integer value, then I need to use the Cint function.
I got it committed to memory now! thank goodness for google groups...

No, you don't have to. Your problem is:
If Me.Field "2" And Me.Field < "8" Then

You are using strings for "2", you should use

If Me.Field 2 And Me.Field < 8 Then
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com


Oct 4 '08 #7

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

Similar topics

24
by: jason | last post by:
Hi Ray...a while ago you explained an elegant solution to enable me to CREATE and EDIT existing tables and queries inside my online access 2000 database.... could you provide refresher links on...
4
by: slc | last post by:
Help, I'm trying to make the following asp code work using a DNS-Less connection on a windows 2000 server running IIS and ODBC 4.0 driver. The Access database (odbc_exmp.mdb) was made using...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
1
by: Julius Mong | last post by:
Dear all, according to the ASV3 manual known problem section, to make an <a> execute some Javascript onclick: ...
3
by: John | last post by:
Hi I have an access app that runs fine on access 2000 on a windows 2000 pc. I installed access 2000 on a second win xp pro pc with ms office xp small business already installed. When I run the...
1
by: trinity | last post by:
Hello all, First, I am grateful for this forum and all comments that will be posted. I am designing a database that compiles data from sewage treatment plants. Mostly the data is numeric. ...
1
by: lphuong | last post by:
I'm working on a db on Access 2000. I'm also linking that db to some tables on SQL Server Enterprise Manager. My code is stop running at the statement, set db=CurrentDb()? Is that the reason I...
4
by: ZRexRider | last post by:
Hi, I have an MS-Access 2000 application that is connected to a MS-SQL Server 2000 backend by linking tables through a DSN-Less connection. No problems at all with that part. This application...
2
by: worldbadger | last post by:
When I moved my Access 2000 program to Win XP Home, none of the wizards are working. Anyone know why? Since I know it will come up (at least it was the first question Microsoft asked) I do have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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,...
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...

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.