473,586 Members | 2,702 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 2001
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
4270
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 value. I tried attaching a specific message for this in the table properties, but was unsuccessful. Can this be done? I then opted for Not Is Null...
2
2683
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 of my fields. I have a table called "Product" and two of the fields included in this table are "Cost Price" and "Retail Price". I need to create a...
0
2329
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 necessary fields are shown here): tblBudgetCategories catName:Text catTaxTrack:Yes/No tblBudgetPeriods
6
3683
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 new records. The Validation Rule: <>!! was made using the expression builder. The rule produces this error: The expression you entered in the...
4
2709
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 If the message contains the word porn, can I block the whole message using a validation rule
10
5706
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 form the control is on? Basically I have a number of controls in a form that are required, and to check it I am setting the Validation Rule to...
1
1434
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. What would the validation rule look like in the table design view for this field to achieve this?
6
8146
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 it. We are building a database for a condo rental company and the rental transaction table includes an arrival date and a departure date. We need...
1
1013
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 with
1
2076
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 in which the append fails and the reported error is validation rule. The table being appended to (tblClusters) has only 1 field with a...
0
7911
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7954
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8215
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5710
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1179
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.