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?
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: - IsDate("20/" & [AlsText1])=True Or Is Null
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)
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. - Private Sub txtDate_AfterUpdate()
-
If IsDate(txtDate) Then
-
txtDate = Format(CDate(txtDate), "mm/yyyy")
-
Else
-
txtDate = ""
-
MsgBox 'Whatever
-
End If
-
End Sub
Thank you for you help. This worked great. Sorry it took so long to get back to you. Thanks again.
NeoPa 32,567
Recognized Expert Moderator MVP
No problem Alan.
It's good to hear that it helped :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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,
|
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?
|
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...
|
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.
| |
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()
{
|
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...
|
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
|
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...
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |