Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table and Validation rule

Status
Not open for further replies.

Superguppie

Technical User
Jan 19, 2005
107
0
0
NL
hey there,

when the field (in a table) is 1 or more, then the checkbox must be checked, if it is 0 then it must be unchecked. how is this done in the validation rule, i had this:

If[Aantal]>=1 then [Voorraad]=Waar

but it seems not right.
can anyone explane why, and give the right validationrule

Thanks in advance

Superguppie
 
Hi superguppie,

I'm not sure what you are triyng.

"Validation Rule" is to be sure that the value entered is valid.

I think that you might want to make a "Default Value". but I'm not sure:m did you have a field named 'Aantal' (for amount) and a field named 'Voorraad' (for stock)? and you want that the field 'Voorraad' should fill automatically by checking the value of 'Aantal'?

(if so, then you should enter the following as the 'Default Value' for 'Voorraad':
Code:
[b]IIf[/b]([Aantal]>0, [b]true[/b], false

- the If in your code, is handling only one case - because if 'Aantal' is NOT >=1 , then you didn't tell which value...
while IIf have both parts.

- also, if you have 'Voorraad' as field, it's 'Data Type' should be Yes/No ;-)

or, maybe you have a checkbox on a form - not as a field in a table?)


Hope will help, Ja

- P.S. VBA begrijpt geen Nederlands... Dus, 'waar' - moet altijd 'true' zijn...
 
ok, well thats a start, but when a user sells something, he does that in another form, then the Aantal, will drop, lets say it goes to 0 now, will the checkbox automaticly be unchecked, thats what i am looking for.


P.S.

Dus eigenlijk als het aantal 0 is of wordt moet de checkbox uitgevinkt staan, wordt het weer 1 of meer, moet hij automatisch weer gevinkt staan.
 

Hi supperguppie,

the question is: do you have a field in your table named 'Voorraad' that automatically get checked/unchecked,
or,
you have a checkbox control on your form that should automatically be checked/unchecked?

(I am thinking that the second option is right, because it's not a good idea to have a field for values that can be calculated)

Ja
 
its a field in my table thats gets checked by a VBA code in the form, i was hoping that there was a code for VBA to do this.....
 
Also its in the table because the checkbox is needed in a report:D

superguppie
 

Hi

I think you can do it by code in VBA.
try the following in the 'After Update' event of the control that is bound to the Aantal field:
Code:
Voorraad = (Aantal > 0)
I hope this will do it.

een prettige dag...
Ja
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top