Jump to content

Validate field 2 if field 1 is not empty


This topic is 6488 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello.

For example, I have two number fields: N1 and N2.

How can I validate the field N2 so that it cannot be left empty when the data was entered in N1 field?

In other words, if the user will enter smth in N1, he/she must enter smth in field N2 as well.

Many thanks.

FileMaker Version: 6

Platform: Windows 2000

Link to comment
Share on other sites

Why not a lookup ?

Create a cTriggerKey that would match your serial or ID field.

Then set N2 to lookup its value from N1.

Don't forget to uncheck the box "if field is empty"

the cTrigger could look something like

Case(N1*GetField("N2"),(Status(CurrentTime)*0)+Serial,(Status(CurrentTime)*0)+Serial)

Then, whenever you try to enter N2 when N1 is empty, the value you entered will just be nulled. Else, N2 would lookup N1 value.

HTH

FileMaker Version: 6

Platform: Mac OS 9

Link to comment
Share on other sites

Vasilek,

If you use a third field that is required to be validated by (N1=N2), it will give you a message if they aren't the same. I adjusted N2 so that it automatically fills in when N1 is originally filled-in. Otherwise, you never get the chance to get to N2 before the "not valid" message appears.

Hope this helps.

Paul smirk.gif

FileMaker Version: 6

Platform: Windows XP

Two Field Validation.zip

Link to comment
Share on other sites

Sorry, I didn't mean that 'smth' must be equal 'smth'. On the contrary, value in N1 is a price and value is N2 is minimum qty. So, when the user will enter the price in N1, he/she must enter a minimum qty of the product can be sold at this price in N2.

Link to comment
Share on other sites

Well, this value wouldn't come here by magic.

So if it is stored in some place, I still believe a lookup (pretty easy one this time) is what you need to grab it.

Or you might enlight us a bit more... crazy.gif

Well, in any case, here's one way to make sure your user would enter some value in N2 if N1 is not empty.

Now, a script would just bypass any field validation, as well as imports.

FileMaker Version: 6

Platform: Mac OS 9

Field2Validation.fp5.zip

Link to comment
Share on other sites

For the field validation for N2, validate by calculation:

If(not IsEmpty(N1), not IsEmpty(N2),1)

Uncheck "Validate only if field has been modified".

Or you could change it so N2 must be empty if N1 is empty:

If(IsEmpty(N1), IsEmpty(N2), not IsEmpty(N2))

You could also modify this to check to a range of numbers.

Link to comment
Share on other sites

Yep. It's a powerful logical operator that states either operand may be true, but not both. It's also known as the exclusive or (hence the x), as opposed to the inclusive OR (either or both operands may be true).

Link to comment
Share on other sites

  • Newbies

I found this discussion because I was trying to do the same thing . . . guarantee that if one field is filled in, the second must also be filled in. I actually tried If(IsEmpty(N1), IsEmpty(N2), not IsEmpty(N2)) as the field validation for N2. The result is that the validation never kicks in.

Do I need to use the third field for the validation step?

Here's another wrinkle - maybe I'm going about this the wrong way: I would like N2 to be filled in by a script that opens another file.

The overall plan for my solution is that after the user enters info in one of two fields (N1 or N3) they must execute a script which creates a related record in the second file. They must use Script 1 if they filled in N1, and Script 3 if they filled in N3. My idea is that Script 1 is they only way they can fill in N2, which is not on the layout. Thus, if they don't execute the correct script they will not be permitted to exit the record if I make the validation strict. However, the validation does not occur. Am I missing something obvious?

Link to comment
Share on other sites

It sounds like you want your field validation on N3 instead. Since N2 would only be filled in by a script, you should not have field validations for that field.

Or since you will be calling a script anyway to fill in N2, don't use field validations at all. Instead check your data entry when the script is launched--the script checks that only one field is filled in, then it branches to the correct sub-script.

Link to comment
Share on other sites

  • Newbies

You're correct, I want validation on N3 - I got lost in the example there and misstated myself! Nevertheless, since the validation is being ignored, I'm trying to figure out how I can ensure that the field is checked to see if it's valid.

Link to comment
Share on other sites

This topic is 6488 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.