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

need validation rule for monthly period (mm/yy) on textbox control

MS Access 2000... I have a textbox control on a form that requires a validation rule that will check for valid monthly periods to be entered. Example... allowable values for March 2006 would be 03/06 or 3/06 or 03/2006 or 3/2006. I have thought of using the left, right, & instr functions but am not having much luck. The control must remain a textbox. The form name is "AlsForm" and the textbox controls name is "AlsText1". Any ideas out there?
Jan 22 '07 #1
5 2457
dima69
181 Expert 100+
MS Access 2000... I have a textbox control on a form that requires a validation rule that will check for valid monthly periods to be entered. Example... allowable values for March 2006 would be 03/06 or 3/06 or 03/2006 or 3/2006. I have thought of using the left, right, & instr functions but am not having much luck. The control must remain a textbox. The form name is "AlsForm" and the textbox controls name is "AlsText1". Any ideas out there?
Use this for control's validation rule:
Expand|Select|Wrap|Line Numbers
  1. IsDate("20/" & [AlsText1])=True Or Is Null
Jan 22 '07 #2
nico5038
3,080 Expert 2GB
Best to place the code behind a Save button.

Try:

IF val(left(me.AlsText1,INSTR(me.AlsText1,"/"))) < 0 or val(left(me.AlsText1,INSTR(me.AlsText1,"/"))) > 12 then
' action invalid month
endif

if len(mid(me.AlsText1,INSTR(me.AlsText1,"/")+1)) <> 2 and
len(mid(me.AlsText1,INSTR(me.AlsText1,"/")+1)) <> 4 then
' invalid year length action
endif

Idea ?

Nic;o)
Jan 22 '07 #3
NeoPa
32,556 Expert Mod 16PB
MS Access 2000... I have a textbox control on a form that requires a validation rule that will check for valid monthly periods to be entered. Example... allowable values for March 2006 would be 03/06 or 3/06 or 03/2006 or 3/2006. I have thought of using the left, right, & instr functions but am not having much luck. The control must remain a textbox. The form name is "AlsForm" and the textbox controls name is "AlsText1". Any ideas out there?
In your position, rather than simply controlling the input, I'd let them put in whatever they like then, in the AfterUpdate event I'd check it and convert it to your preferred format.
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtDate_AfterUpdate()
  2.     If IsDate(txtDate) Then
  3.         txtDate = Format(CDate(txtDate), "mm/yyyy")
  4.     Else
  5.         txtDate = ""
  6.         MsgBox 'Whatever
  7.     End If
  8. End Sub
Jan 23 '07 #4
Thank you for you help. This worked great. Sorry it took so long to get back to you. Thanks again.
Mar 19 '07 #5
NeoPa
32,556 Expert Mod 16PB
No problem Alan.
It's good to hear that it helped :)
Mar 19 '07 #6

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

Similar topics

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...
7
by: A.M | last post by:
Hi, I have a validation control in my page that upon any invalid data, it disables all buttons in the page. basicly i don't have any postback in the page if the validator finds any error. How...
3
by: VB Programmer | last post by:
Can you make a required field validator optional? I know it sounds crazy, but.... Let's say I have a signup form. It consists of 2 sections. The top section is a "GOLD MEMBER" section. It...
1
by: Jack | last post by:
Hi, I have a page with a repeater control that contains textboxes. I'm trying to create a validation class that is called by my page. A method in this class iterates through all the controls...
2
by: Tim Frawley | last post by:
Source code attached indicates my problem with validation and a button bar save button. Fill the Textbox with some text then tab off the control. The message box will display the text in the...
5
by: Lloyd Dupont | last post by:
On my page the user is ask to set of question. Say there I have 2 controls like that == pseudo-C#-code for my control == class MyControl : CompositeControl { TextBox text; LinkButton button ...
0
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I'm having trouble working with a Summary Validation control. I need to click my submit button twice for the Summary to display when validation errors occur on the page. Background: My page...
1
by: bruce.dodds | last post by:
I would like to set up a field validation rule to limit first name characters to alphabetic characters, period, and space. I've tried a number of variations on this rule: Is Null Or...
4
by: HenrikL | last post by:
Hi. I have a textbox that have a binding on it with converter and validationrules. When a validation error ouccur the foreground of the textbox will change to red cause it has a style.triggers...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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.