473,399 Members | 3,888 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,399 software developers and data experts.

Validation rule in access

76
Hello,

I have a validation rule in a text box on a form. The rule is that if Combo12 starts with "Credit Hours -*" than only allow numbers less than or equal to 2 in there. Any number of words could come after credit hours, hence the wildcard character. The formula that I'm using is:

[Hours]<=2 Or [Combo12]<>"Credit Hours -*"

but it isn't working. What am I doing wrong?

Thanks,

Charlie
Dec 29 '06 #1
14 3733
How about something like

Val(Mid(thestring,start position of #,Lenght of #))

If you need to get total length of string for Length of #, you can use Len

Ivan
Dec 29 '06 #2
ckpoll2
76
That didn't seem to work. Do you know of any variation of the formula that I listed in my earlier thread? I'm thinking it has something to do with using "like", but I'm not really sure.

Thanks for your help
Dec 29 '06 #3
Are you comparing what is entered to 2 seperate parameters "hours" and "combo 12"? Does your user have to enter the text "credit hours - "?

If all they are really entering is a number, just compare it locally for that specific number.

If this is coming from a table that has the text "credit hours - " already there you are better off using a query.

Ivan
Dec 30 '06 #4
ADezii
8,834 Expert 8TB
Hello,

I have a validation rule in a text box on a form. The rule is that if Combo12 starts with "Credit Hours -*" than only allow numbers less than or equal to 2 in there. Any number of words could come after credit hours, hence the wildcard character. The formula that I'm using is:

[Hours]<=2 Or [Combo12]<>"Credit Hours -*"

but it isn't working. What am I doing wrong?

Thanks,

Charlie
'Assuming the Text Box is called txtTest, try this in the BeforeUpdate()
'Event of this Text Box to enforce Validation
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtTest_BeforeUpdate(Cancel As Integer)
  2. If Me![Combo12].Value Like "Credit Hours -*" Then
  3.   If Me![txtTest].Value <= 2 Then
  4.   Else
  5.     MsgBox "Value must be <= 2"
  6.     Cancel = True
  7.   End If
  8. End If
  9. End Sub
Dec 30 '06 #5
NeoPa
32,556 Expert Mod 16PB
Hello,

I have a validation rule in a text box on a form. The rule is that if Combo12 starts with "Credit Hours -*" than only allow numbers less than or equal to 2 in there. Any number of words could come after credit hours, hence the wildcard character. The formula that I'm using is:

[Hours]<=2 Or [Combo12]<>"Credit Hours -*"

but it isn't working. What am I doing wrong?

Thanks,

Charlie
Try something like
Expand|Select|Wrap|Line Numbers
  1. [Hours]<=2 Or [Combo12] Not Like "Credit Hours -*"
Dec 31 '06 #6
MMcCarthy
14,534 Expert Mod 8TB
Logically, I don't think this rule will work.

You are saying that the the rule is that the hours have to be less than 2 or the Combo12 not like "Credit Hours -*". I don't think you can do this kind of logic with a validation rule and would suggest you look at Adezii's solution.

Mary
Jan 1 '07 #7
NeoPa
32,556 Expert Mod 16PB
You're right Mary.
Rather than VBA code (which would work) you could try :
Expand|Select|Wrap|Line Numbers
  1. <=IIf([Combo12] Like "Credit Hours -*",2,99999)
Jan 1 '07 #8
MMcCarthy
14,534 Expert Mod 8TB
You're right Mary.
Of course I'm right, I'm always right. :D
Jan 1 '07 #9
NeoPa
32,556 Expert Mod 16PB
Of course I'm right, I'm always right. :D
Come now Mary, you should be able to remember more than half of your posts :wicked grin:
Jan 1 '07 #10
MMcCarthy
14,534 Expert Mod 8TB
Come now Mary, you should be able to remember more than half of your posts :wicked grin:
Half, HALF !!!!!!!!
Jan 2 '07 #11
NeoPa
32,556 Expert Mod 16PB
Come now Mary, you should be able to remember more than half of your posts :wicked grin:
Half, HALF !!!!!!!!
Maybe that was a little churlish - Five eighths maybe.
Jan 2 '07 #12
MMcCarthy
14,534 Expert Mod 8TB
Maybe that was a little churlish - Five eighths maybe.
I refuse to disintegrate this argument into it's normal childish level. I am above such juvenile behaviour.
Jan 2 '07 #13
NeoPa
32,556 Expert Mod 16PB
I refuse to disintegrate this argument into it's normal childish level. I am above such juvenile behaviour.
Lol Yeah, and what about the Leprechauns? Are they real too?
Jan 2 '07 #14
MMcCarthy
14,534 Expert Mod 8TB
Lol Yeah, and what about the Leprechauns? Are they real too?
Loathe as I am to repeat myself ....

GET LOST ADE :D
Jan 2 '07 #15

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

Similar topics

3
by: Dalan | last post by:
I apparently need a bit of assistance regarding the structure of some validation code on the BeforeUpdate or AfterUpdate event on a form for several fields that need to controlled. I did search the...
2
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...
7
by: Mathew Hill | last post by:
I am a beginner to the more technical aspects of Microsoft Access (2000) and was wondering if any one can help? I have a field in a table called: ADMIN NUMBER This field should have 4...
0
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...
5
by: Don Sealer | last post by:
I've got a validation rule that says something like =xx or xxx or zzzz. Though I may not have described it well it does work fine and that is really not my question. Here's what I'd like to do....
3
by: BrianB830 | last post by:
Hello all, I have a quick question regarding an MS Access database I'm creating. In the entity "ORDER", I have the attributes "Order Date" and "Delivery Date". I need to create a validation...
4
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...
1
by: toby989 | last post by:
Hi All I was wondering how a emailaddress validation rule looks like. I was hoping that either a wizard that offers example fileds or the example database that comes with access would provide...
10
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...
7
by: sharsy | last post by:
Hi guys, I would like to setup a validation rule for a database in microsoft access that restricts data entry so that a certain field can only be filled in if another field has a specific answer...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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
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,...

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.