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

Home Posts Topics Members FAQ

validation rule on a control

86 New Member
Hi there.

So I have a table called "users" and a form created from that table with some of the fields, including
  • First_name
  • Last_name
  • address
  • email
  • windowsID

The table has existing records and the purpose of this form is to manage it for future new users to be added.

I wrote a sub and put it to the email setfocus method that automatically takes the first letter of the first_name and the full last name to create the email as well as add the @gmail.com part
Expand|Select|Wrap|Line Numbers
  1. email.text = (Mid(first_name.value,1,1) & Mid(last_name.value,1) & "@gmail.com")
  2.  
i did the same for windowsID, where i take only the first two letters of the first_name and the first letter of the last_name
Expand|Select|Wrap|Line Numbers
  1. windowsID.text = (Mid(first_name.value,1,2) & Mid(last_name.value,1,1))
  2.  
however, this won't work for records that do not follow this convention.. such as if the first_name of one user is "Bobby" and last_name is "Smith". the email should have been bsmith@gmail.co m. however, the user's email in that record is BobbySmith@gmai l.com.

i want to make sure that if the previous records are already populated with text, do not update the field using the code above. the stuff above will only "run" when there's a new record added. also have some kind of validation that if they click on the email field without putting in their firstname and lastname, a msgbox will appear telling them to fill in whichever is blank.

Thanks!

hope this isn't too hard to accomplish.
Jul 26 '11 #1
1 1497
NeoPa
32,567 Recognized Expert Moderator MVP
It's actually very easy Jeffrey. You simply set the .DefaultValue property of the control instead of its .Value property (Generally not a good approach to work with .Text unless it is a specifically textual issue).

The default value is only used for entering new records, and can easily be overridden by the operator if found to be inappropriate ;-)

It also has the benefit of not marking the new record as having been changed before the operator types anything in.
Jul 26 '11 #2

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

Similar topics

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 validation rule so that the Cost Price is always less than the Retail Price. I have tried...
3
4072
by: GGerard | last post by:
Hello In a text box, I would like the user to be able to enter only a number from 0 to 100 (including decimals Ex: 24.56) so I wrote this in the Validation Rule Propertie of the text box : >= 0 And <=100 This works good when the user enters numbers in the text box but when letters are entered Access displayed a default message instead of the Validation Text message.
6
3684
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 Form control's Validation Rule doesn't contain the Automation object 'Tables' If I use simply: ...
1
2545
by: cga1982 | last post by:
I have a text box (for a password) with a validation rule that checks this password against another text box on the form and either lets you continue or tells you that the password is incorrect and that you have to try again. The problem is that I can just tab right through this text box control. If I type something in the text box it then does make the validation check but I can still just tab past it without entering a thing. Any ideas...
4
2713
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
5
2469
by: alanpike | last post by:
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?
10
5712
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 "<>"IsNull" so that when the user tries to tab through/click out of a required area without entering...
3
1284
by: KPR1977 | last post by:
I want to set a validation rule that will not allow me to input data in field1 in TableA that is not found in TableB under field2. Basically, Table B under field 2 has the following row entries: Apple, Pear, Lemon, Orange. When I input data in field 1 for Table A I want it to give me an error message if try and input Watermelon (since Watermelon doesn't exist anywhere in Table2.) If anyone could help me out with this, it would be much...
12
24832
alakazamm
by: alakazamm | last post by:
I am building a database on Access 2000 which include a Customer Details table. In this Customer Details table there is a 'Post Code' field which I am required to make an Input Mask to limit the values. I have used the following Input Mask: LL##&AL? This Input Mask should be able to contain the following types of Post Code: LE4 5GH
1
2079
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 validation rule: , with Byte Field Size property setting. The validation rule is >0. The field's default...
0
8196
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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
8504
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.