473,626 Members | 3,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

7 New Member
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 2469
dima69
181 Recognized Expert New Member
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 Recognized Expert Specialist
Best to place the code behind a Save button.

Try:

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

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

Idea ?

Nic;o)
Jan 22 '07 #3
NeoPa
32,567 Recognized Expert Moderator MVP
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
alanpike
7 New Member
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,567 Recognized Expert Moderator MVP
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
2330
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
7
2866
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 can have the validator just disable certain control's postback and other part of page continue their functionality. Thanks,
3
1526
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 has required validators for name, address, etc... The next section is the "BRONZE MEMBER" section. It also has required validators for the same fields. The user only has to fill out 1 set of info. Any thoughts on how to accomplish this?
1
4716
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 on the page. On encountering a TextBox control, it looks at the ID to discern the field the TextBox represents, and then creates the appropriate validation controls and adds them to the page. The controlToValidate property of each validation...
2
6701
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 textbox from the Validating event. Now put the focus back on the textbox click the button bar button. Nothing happens. The form causes validation is true, so is the button bar and the control.
5
1901
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 override void CreateChildControl() {
0
2129
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 contains a radio control which the user must answer to finish the page entry. If user hits submit button without selecting item from control, summary validation error displays. In this case one click is sufficient. Once the user selects choice on...
1
4094
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 UCase(Trim()) Like "" but the first name "GRACE J." keeps getting rejected. If anyone has a tip on how to accomplish this edit please let me know. BTW, I know that J. is a middle initial, but in this case we have to
4
8216
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 that are connect to it and it works as it should.. What I wanna to do it in some special case I wan to test tb.Text.Equals("myTestStr") or if the text lenght too large etc.. and I wanna same behave as a validation has error on the textbox if the...
0
8265
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8637
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7193
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.