473,508 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

validation rule problem?

283 Contributor
Hello all,

Im having some problems creating a validation rule with VBA. What I have is a form with a text box. When you start to type in the text box I want to have a validation rule set so you can only type certain numbers.

The problem I am having is with this code. It works fine but for some reason I can not contiune on with more ValideRule settings except for the first line. I cant figure out what is wrong with my syntax to get it to read the next line as still part of the first line.

I have tried using (,_) (& _) (" _) and many more variations so it will read the second and third lines but no luck.

Any help would be great!



Expand|Select|Wrap|Line Numbers
  1. Dim strValidRule as String
  2. Dim strValidText as String
  3.  
  4. strValidRule = "Between 1 And 10" Or "Between 20 And 30" _
  5.      Or "Between 40 And 50" Or "Between 60 And 70" _
  6.      Or "Between 80 And 90" Or "Between 100 And 110"
  7.  
  8.     strValidText = "Invalid Number."
  9.  
  10. Text7.ValidationRule = strValidRule
  11. Text7.ValidationText = strValidText
  12.  
  13.  
Nov 3 '10 #1
2 1994
Mariostg
332 Contributor
Try this:
Expand|Select|Wrap|Line Numbers
  1. strValidRule = "'Between 1 And 10' Or 'Between 20 And 30'" & _
  2.      " Or 'Between 40 And 50' Or 'Between 60 And 70'" & _
  3.      " Or 'Between 80 And 90' Or 'Between 100 And 110'"
  4.  
Nov 4 '10 #2
slenish
283 Contributor
Hi Mariostg,

Thanks a lot for the reply. I took your example and found that I just had to make one small adjustment and now it works great.

Really apprecitea your help! :D

adjusted code below
Expand|Select|Wrap|Line Numbers
  1. strValidRule = "Between 1 And 10 Or Between 20 And 30" & _ 
  2.      " Or Between 40 And 50 Or Between 60 And 70" & _ 
  3.      " Or Between 80 And 90 Or Between 100 And 110"
  4.  
Nov 6 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
4262
by: Dalan | last post by:
This ought to be simple enough, but not certain which to use. I have a few fields set to Require data to be entered; however, the message displayed by Access 97 is too generic to be of any real...
2
2674
by: Joey P | last post by:
Hi all, I am doing a project for university whereby i have to implement a simple database related to a frozen foods company. I am having some trouble though creating a validation rule for one...
0
2322
by: Steve V | last post by:
I'm using Access 2000 to build a budgeting/tracking database. Can I make a validation rule (using VBA) that checks the data as if the record has already been added? I've got 5 tables (only the...
6
3676
by: Chuck | last post by:
A97. A database has a table: tblA which has a single text field, B. It is a primary field, indexed and no duplicates. It is used as a lookup for table tblC. A form based on tblA is used to add...
4
2705
by: ron | last post by:
I have a access based guest book. I want to create a validation rule to block certain words or parts of a srting. How do i do this? ie: this is a nice site. come visit my porn site at www.abc.zy...
10
5685
by: gweasel | last post by:
What is the best way to apply a Validation Rule - or rather, where is the best place to put it? Is there an advantage to putting it on the field in the table vs setting the validation rule on the...
1
1429
by: azizrasul | last post by:
I'm dealing with a Hospital No. in a table which follows the format that the first character is an uppercase letter and the remaining six characters have to be numbers e.g T123456, G564398, etc. ...
6
8125
by: Ledmark | last post by:
Hello - I am in a class for Access 2007 Database apllication design and we are covering types of Validation rules. We have a problem that I'm trying to solve but have no idea how to go about writing...
1
1003
by: adsdldsfasd | last post by:
Hi guys. I have an Access DB that has a Course table with a primery key CourseSignature which has a validation rule Like "###". For example CSCB343. When I try to enter a value in the DB...
1
2065
by: MLH | last post by:
Anyone remember if A97 append query failure would ever report data breaking validation rule when such was not the case. I have an old SQL statement - several years old now. I've encountered a case...
0
7127
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
7331
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
7391
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...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5633
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,...
0
4713
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
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.