Validation

ProcalX

Registered User.
Local time
Today, 10:07
Joined
Jan 12, 2006
Messages
16
I have a table called Inspection, there are two fields:

- Damage To Property // data type is Yes/No
- Damage Comments // data type is text

How would i go about setting the validation - if Damage To Property is data type "No", disable the "Damage Comments" field. (ie grey it out).

any help would be greatly appreciated..
 
In the AfterUpdate event of the 'Damage to Property' field, you could add code along the lines of
Code:
If [Forms]![[I]form name[/I]]![Damage to Property] = True Then
      [Forms]![[I]form name[/I]]![Damage Contents].Enabled = True
Else
      [Forms]![[I]form name[/I]]![Damage Contents].Enabled = False
End If
This assumes that the fields on the form are are a textbox (Contents) and a checkbox (Property), and are called the same as the the columns in the table.

If there is a chance that the user could complete the 'Contents' field before checking/unchecking the 'Property' field, you might want to put something in the 'Contents' after update event, along the lines of
Code:
If IsNull([Forms]![[I]form name[/I]]![Damage Contents]) Then
      [Forms]![[I]form name[/I]]![Damage to Property] = False
Else
      [Forms]![[I]form name[/I]]![Damage to Property] = True
End If
Just to keep things consistent and prevent anyone from completing a comment and forgetting to check the box.

Hope that helps.
 
Thanks for that, thats brilliant..
 
On the same subject, I have two fields within a table:

- Rental Start Date
- Rental End Date

both these fields are set to data type "Date/Time" I want to set a validation rule so that the minimum time period is 3 months and the maximum is 12 months rental. How would i go about doing this?
 
Also where can i learn how to code validation like this, i realise it is relatively basic, but if u do not know the commands then u cant really start..
 
I can't speak for anyone else, but I taught myself by working out exactly what I wanted to do in English, then searching for keywords (validation, enable, visible, etc.), on this forum and other places. At the risk of sounding like I'm trying to avoid helping, I found I learned the most by copying and adapting other examples.

As long as you've got it clear what you're trying to accomplish, you'd be surprised how easy it is to find examples one can rip off... ahem.. I mean use for inspiration :D

For what you seem to be trying to do, you want to look for the properties of objects on forms (textboxes, comboboxes, checkboxes, etc.) and of forms themselves. Access help is pretty good for this stuff.

I think you'll work the date problem out for yourself. You have two values, you want the difference between the two to be at least three months and no more than twelve months. Start with an 'IF' statement and work from there.
If you get stuck, post again and I'll have a look for you.

Good luck.
 

Users who are viewing this thread

Back
Top Bottom