473,499 Members | 1,974 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.com. however, the user's email in that record is BobbySmith@gmail.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 1484
NeoPa
32,557 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
2674
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...
3
4019
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 : >=...
6
3675
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...
1
2521
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...
4
2704
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...
5
2461
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...
10
5684
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...
3
1278
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: ...
12
24794
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...
1
2062
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...
0
7131
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
7007
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
7220
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...
1
6894
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
7388
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
5470
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,...
1
4919
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...
0
4600
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...
1
665
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.