473,657 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validating field on the basis of the value of another field

Sorry about the unwieldy title, it's difficult to describe it in any
other way.

Basically I have a table in Access 97 which contains a number of
records in different states. When originally created, I do not wish
to make the field Original ID required, however once the state of the
record is changed I require this field to be completed and not be the
value zero.

Tried a number of ValidationRule types at field and table property
value and found as a general rule my validationis too complicated.

i.e. the following was not well received ;)
=iif([Corrected]=Yes, <>0,0) - giving type mismatch errors
any other variant could not be assessed.

Moved to the form itself where the record will change state. I have a
simple save record button and would like to utilise this to validate
the text as follows

Dim strMsg As String

If IsNull(Me![ORIGINAL ID]) Then
If Me!CORRECTED = "Yes" Or Me!Check53 = "Yes" Then
strMsg = "Please Enter Original ID Number"
Else
DoCmd.DoMenuIte m acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
End If

It certainly reads and accepts the code, but when I enter validate
data it still jumps to the save record command and accepts it.

Anyone have any ideas on either how to resolve my code or a better way
of doing things.

Many thanks in advance

Jenni
Nov 12 '05 #1
3 2869
Put all your validations in the BeforeUpdate event of the form?
Nov 12 '05 #2
1. Open the table in design view.

2. Open the Properties box (View menu).

Locate the Validation Rule in the Propeties box, not the one in the lower
pane (which relates to a field, not the rule for the table).

3. Set the property to:
([Corrected] = False) OR ([Original ID] <> 0)

The rule is satisfied if Corrected is False (regardless of what Original ID
contains). If Corrected is not False, then the rule can only be satisifed if
Original ID contains a value other than zero (which means also that it must
contain a value, so cannot be Null).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Jenni" <jc******@strou dandswindon.co. uk> wrote in message
news:9f******** *************** ***@posting.goo gle.com...
Sorry about the unwieldy title, it's difficult to describe it in any
other way.

Basically I have a table in Access 97 which contains a number of
records in different states. When originally created, I do not wish
to make the field Original ID required, however once the state of the
record is changed I require this field to be completed and not be the
value zero.

Tried a number of ValidationRule types at field and table property
value and found as a general rule my validationis too complicated.

i.e. the following was not well received ;)
=iif([Corrected]=Yes, <>0,0) - giving type mismatch errors
any other variant could not be assessed.

Moved to the form itself where the record will change state. I have a
simple save record button and would like to utilise this to validate
the text as follows

Dim strMsg As String

If IsNull(Me![ORIGINAL ID]) Then
If Me!CORRECTED = "Yes" Or Me!Check53 = "Yes" Then
strMsg = "Please Enter Original ID Number"
Else
DoCmd.DoMenuIte m acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
End If

It certainly reads and accepts the code, but when I enter validate
data it still jumps to the save record command and accepts it.

Anyone have any ideas on either how to resolve my code or a better way
of doing things.

Many thanks in advance

Jenni

Nov 12 '05 #3
Many Thanks Allen that worked a treat

For anyone else you may also be interested to know that when i
required muiltiple validation on the fields I could place a similar
statement in the validation rule of the field in my form. This
allowed me to assess twice the contents of one field on the basis of
the check box.

Thanks again

Jenni
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
13999
by: Mark | last post by:
Hi, Im trying to validate a form, all the validating works apart from one field. This particular field must consist of the first 2 characters as letters, & the following 5 as numbers. And if it dosent meet these requirments an error message will be displayed. I have pasted the code (and highlighted the relevant parts) below in the hope that someone can help me out with this. Ive been trying to suss it out all week & it's driving me nuts!...
25
10220
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab Control in the form, and in one of the tabs I have a subform (sfmSiblings) in which I wish to list...
1
2372
by: Emmanuel | last post by:
Hi, I have a webform with some input controls in it. Some of these controls have validation controls assigned. So far so good. I would like to have a validator which validates a field only if the value of another field is a particular value. Lets say i have a country field and a state field, i want to validate that the state field contains a value when the country field is 'US', for example.
7
12940
by: Tizzah | last post by:
What is wrong with that? regex = /^(http|https):\/\/+({1}+)*\.{2,5}(({1,5})?\/.*)?$/ if(field.hpage.value != regex.test(field.hpage.value)){ alert("Bad Homepage") field.hpage.focus() field.hpage.select() return false
5
3921
by: Ryan | last post by:
A binding navigator control adds the following code for when the Save button is clicked: Me.Validate() Me.UserBindingSource.EndEdit() Me.UserTableAdapter.Update(Me.UserDataSet.User)" You can add code to the column changing event for the dataset by using the dataset designer, for example: Private Sub UserDataTable_ColumnChanging(ByVal sender As System.Object, ByVal e As System.Data.DataColumnChangeEventArgs) Handles Me.ColumnChanging If...
232
13242
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first set of examples, after decoding the HTML FORM contents, merely verifies the text within a field to make sure it is a valid representation of an integer, without any junk thrown in, i.e. it must satisfy the regular expression: ^ *?+ *$ If the...
8
3258
by: ivijayan | last post by:
HI. I have the following query:- How do i create field which updates its contents on the basis of data in another field in same record. especially if I have a Date field, how can I change the contents of Status field in the same record based on the date field. for ex:- - If the date is maximum the content in status should be "Current" - If there are 2 records for one ID and if the date field content is minimum the content in status...
16
1951
by: shyamg | last post by:
Hi, this is my javascript validating the fields in mozilla FF but its working and validating only one field. how to write the and how to works the script .................. function Test(){
0
8310
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
8827
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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
8503
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
7333
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
6167
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
5632
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();...
1
2731
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
2
1620
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.