Control with condition

G

Guest

I have a form with a subform : on the form there is a control (textbox) wich
value should depend upon the checking of another control 's value that's
located on the subform (If the value is Null then value1otherwise value2). I
think the IIf function is the one to use but I can't get it to work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance
 
A

AlCamp

Frankie,
You should have shown your code, so we could see the elements involved.
Use your own names...
=IIF(IsNull([Forms]![frmMainForm]![frmSubForm].Form![TextBox]),1,2)
hth
Al Camp
 
P

Penguin

The text box on the main forms Control Source should look like this:

=IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName] Is
Null,"ValueYouWant")

Hope this helps
 
G

Guest

Penguin said:
The text box on the main forms Control Source should look like this:

=IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName] Is
Null,"ValueYouWant")

Hope this helps

I have a form with a subform : on the form there is a control (textbox) wich
value should depend upon the checking of another control 's value that's
located on the subform (If the value is Null then value1otherwise value2). I
think the IIf function is the one to use but I can't get it to work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance

Thanks to both of you for your help.
I am still confused :
A-your solution seems to differ
B- When I write either one (as code) in the BeforeUpdate event of the
textbox [Etat] of main form [F_Interimaires] I keep getting syntax error
Here is what I put within Private Sub procedure:
Penguin proposal -IIf([Forms]![F_Interimaires]![Etat].[Form]![IDContrat]
IsNull,"Candidat","Interimaire")
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
Is there something I should add within Private Sub like a Call function
and if so how do I write it ??
Also, I am based in Paris so please take the time difference into account
when expecting an answer from me .
Waiting to read from you soon
 
T

tina

actually, Al and Penguin gave you basically the same formula. in Penguin's
expression where he refers to

[Forms]![FormName]![ControlName].

he's refering to the subform control, on the main form, that the subform
"sits inside of". it's always confusing to try to explain that in writing
(at least it is for me! <g>).

Solution A
*if the textbox control on your main form is unbound (the ControlSource
property is blank)*, then you can put the IIf() function directly in the
ControlSource - which is what Al and Penguin assumed is the case. the
following should work, and automatically update when the value of the
control in the subform is changed, as

=IIF([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat) Is Null,"Candidat","Interimaire")

note: you have to use the name of the subform control (on the main form),
rather than the name of the subform itself - sometimes the two names are
identical, and sometimes they're not. to get the correct subform control
name, do the following:

1. open your main form in design view.
2. click once on the subform there in design view, to select it.
3. in the Properties box, Other tab, look at the Name property.
4. that's your subform control name.

Solution B
*if the textbox control on the main form is bound to a field in the form's
RecordSource*, and you're intending to save the result of the IF expression
into that field, then you would want to put the code into the AfterUpdate
event procedure of the control on the subform, as

If IsNull(Me!IDContrat) Then
Me.Parent!Etat = "Candidat"
Else
Me.Parent!Etat = "Interimaire"
End If

hth


Frankie said:
Penguin said:
The text box on the main forms Control Source should look like this:

=IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName] Is
Null,"ValueYouWant")

Hope this helps

I have a form with a subform : on the form there is a control (textbox) wich
value should depend upon the checking of another control 's value that's
located on the subform (If the value is Null then value1otherwise value2). I
think the IIf function is the one to use but I can't get it to work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance

Thanks to both of you for your help.
I am still confused :
A-your solution seems to differ
B- When I write either one (as code) in the BeforeUpdate event of the
textbox [Etat] of main form [F_Interimaires] I keep getting syntax error
Here is what I put within Private Sub procedure:
Penguin proposal -IIf([Forms]![F_Interimaires]![Etat].[Form]![IDContrat]
IsNull,"Candidat","Interimaire")
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
Is there something I should add within Private Sub like a Call function
and if so how do I write it ??
Also, I am based in Paris so please take the time difference into account
when expecting an answer from me .
Waiting to read from you soon
 
A

AlCamp

Frankie,
You wrote...
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
(You are missing a right bracket on [IDContrat].)

I don't think Penguin's solution will work, I've never seen the IsNull
function expressed that way, and as far as I know, every IIF syntax must
denote a True and False...
IIf(expr, truepart, falsepart)
I haven't tested his solution... my apoplogies if I'm mistaken

The IIF calculation I posted is meant to be the Control Source of an
unbound field on the main form. Since IDContrat (null or not) always
determines Candidat or Interimaire, it is not necessary to save that
calculation in [Etat]... you just always "display" the calculation on the
main form.
In other words, since you always have IDContrat, you can always
recalculate Etat "on the fly".

Now, if you must save "Candidat" or "Interimaire" in [Etat] in your
table, then "bind" [Etat] to the Etat field, and use the AfterUpdate event
of IDContrat itself with this code...

If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If

will update the field with the correct value.

hth
Al Camp

Frankie said:
Penguin said:
The text box on the main forms Control Source should look like this:

=IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName] Is
Null,"ValueYouWant")

Hope this helps

I have a form with a subform : on the form there is a control (textbox)
wich
value should depend upon the checking of another control 's value
that's
located on the subform (If the value is Null then value1otherwise
value2). I
think the IIf function is the one to use but I can't get it to work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance

Thanks to both of you for your help.
I am still confused :
A-your solution seems to differ
B- When I write either one (as code) in the BeforeUpdate event of the
textbox [Etat] of main form [F_Interimaires] I keep getting syntax error
Here is what I put within Private Sub procedure:
Penguin proposal -IIf([Forms]![F_Interimaires]![Etat].[Form]![IDContrat]
IsNull,"Candidat","Interimaire")
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
Is there something I should add within Private Sub like a Call function
and if so how do I write it ??
Also, I am based in Paris so please take the time difference into account
when expecting an answer from me .
Waiting to read from you soon
 
M

Marshall Barton

AlCamp said:
I don't think Penguin's solution will work, I've never seen the IsNull
function expressed that way, and as far as I know, every IIF syntax must
denote a True and False...
IIf(expr, truepart, falsepart)
I haven't tested his solution... my apoplogies if I'm mistaken


FYI, The xx Is Null syntax will work fine in SQL (where it
is standard, preferred, and more efficient then IsNull()),
in control source expressions and the Eval() function.
However that syntax is not recognized in the VBA environment
(where it would conflict with the IS operator).

Most of the time it doesn't make much difference, but it is
still important to keep the two separate and different
expression environments clear in your mind.

Another SQL operator that can be quite useful in a control
source expression is IN. For example:

=IIf(xx In(2,5,7), True, False)

Unfortunately, VBA never heard of IN so you'd have to use
several lines of code to achieve the same result (or wrap
the above in the Eval function).
 
G

Guest

AlCamp said:
Frankie,
You wrote...
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
(You are missing a right bracket on [IDContrat].)

I don't think Penguin's solution will work, I've never seen the IsNull
function expressed that way, and as far as I know, every IIF syntax must
denote a True and False...
IIf(expr, truepart, falsepart)
I haven't tested his solution... my apoplogies if I'm mistaken

The IIF calculation I posted is meant to be the Control Source of an
unbound field on the main form. Since IDContrat (null or not) always
determines Candidat or Interimaire, it is not necessary to save that
calculation in [Etat]... you just always "display" the calculation on the
main form.
In other words, since you always have IDContrat, you can always
recalculate Etat "on the fly".

Now, if you must save "Candidat" or "Interimaire" in [Etat] in your
table, then "bind" [Etat] to the Etat field, and use the AfterUpdate event
of IDContrat itself with this code...

If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If

will update the field with the correct value.

hth
Al Camp

Frankie said:
Penguin said:
The text box on the main forms Control Source should look like this:

=IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName] Is
Null,"ValueYouWant")

Hope this helps

On Mon, 10 Jan 2005 14:01:05 -0800, "Frankie"

I have a form with a subform : on the form there is a control (textbox)
wich
value should depend upon the checking of another control 's value
that's
located on the subform (If the value is Null then value1otherwise
value2). I
think the IIf function is the one to use but I can't get it to work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance

Thanks to both of you for your help.
I am still confused :
A-your solution seems to differ
B- When I write either one (as code) in the BeforeUpdate event of the
textbox [Etat] of main form [F_Interimaires] I keep getting syntax error
Here is what I put within Private Sub procedure:
Penguin proposal -IIf([Forms]![F_Interimaires]![Etat].[Form]![IDContrat]
IsNull,"Candidat","Interimaire")
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
Is there something I should add within Private Sub like a Call function
and if so how do I write it ??
Also, I am based in Paris so please take the time difference into account
when expecting an answer from me .
Waiting to read from you soon


Since [Etat] is bound to a table I opted for AfterUpdate Event on [IDContrat] on subform with your solution or Tina's. The problem is that it still does not work and I really don't get it!!!
The subform is used on another form, could that make a difference ??
Thanks for your continuing support
 
T

tina

The subform is used on another form, could that make a difference ??

do you mean the subform is used on another main form *in addition to* form
F_Interimaires? or another main form *instead of* form F_Interimaires?

please explain your setup in a little more depth.


Frankie said:
AlCamp said:
Frankie,
You wrote...
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
(You are missing a right bracket on [IDContrat].)

I don't think Penguin's solution will work, I've never seen the IsNull
function expressed that way, and as far as I know, every IIF syntax must
denote a True and False...
IIf(expr, truepart, falsepart)
I haven't tested his solution... my apoplogies if I'm mistaken

The IIF calculation I posted is meant to be the Control Source of an
unbound field on the main form. Since IDContrat (null or not) always
determines Candidat or Interimaire, it is not necessary to save that
calculation in [Etat]... you just always "display" the calculation on the
main form.
In other words, since you always have IDContrat, you can always
recalculate Etat "on the fly".

Now, if you must save "Candidat" or "Interimaire" in [Etat] in your
table, then "bind" [Etat] to the Etat field, and use the AfterUpdate event
of IDContrat itself with this code...

If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If

will update the field with the correct value.

hth
Al Camp

Frankie said:
:

The text box on the main forms Control Source should look like this:

=IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName] Is
Null,"ValueYouWant")

Hope this helps

On Mon, 10 Jan 2005 14:01:05 -0800, "Frankie"

I have a form with a subform : on the form there is a control (textbox)
wich
value should depend upon the checking of another control 's value
that's
located on the subform (If the value is Null then value1otherwise
value2). I
think the IIf function is the one to use but I can't get it to work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance

Thanks to both of you for your help.
I am still confused :
A-your solution seems to differ
B- When I write either one (as code) in the BeforeUpdate event of the
textbox [Etat] of main form [F_Interimaires] I keep getting syntax error
Here is what I put within Private Sub procedure:
Penguin proposal -IIf([Forms]![F_Interimaires]![Etat].[Form]![IDContrat]
IsNull,"Candidat","Interimaire")
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
Is there something I should add within Private Sub like a Call function
and if so how do I write it ??
Also, I am based in Paris so please take the time difference into account
when expecting an answer from me .
Waiting to read from you soon


Since [Etat] is bound to a table I opted for AfterUpdate Event on
[IDContrat] on subform with your solution or Tina's. The problem is that it
still does not work and I really don't get it!!!
 
G

Guest

tina said:
The subform is used on another form, could that make a difference ??

do you mean the subform is used on another main form *in addition to* form
F_Interimaires? or another main form *instead of* form F_Interimaires?

please explain your setup in a little more depth.


Frankie said:
AlCamp said:
Frankie,
You wrote...
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
(You are missing a right bracket on [IDContrat].)

I don't think Penguin's solution will work, I've never seen the IsNull
function expressed that way, and as far as I know, every IIF syntax must
denote a True and False...
IIf(expr, truepart, falsepart)
I haven't tested his solution... my apoplogies if I'm mistaken

The IIF calculation I posted is meant to be the Control Source of an
unbound field on the main form. Since IDContrat (null or not) always
determines Candidat or Interimaire, it is not necessary to save that
calculation in [Etat]... you just always "display" the calculation on the
main form.
In other words, since you always have IDContrat, you can always
recalculate Etat "on the fly".

Now, if you must save "Candidat" or "Interimaire" in [Etat] in your
table, then "bind" [Etat] to the Etat field, and use the AfterUpdate event
of IDContrat itself with this code...

If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If

will update the field with the correct value.

hth
Al Camp



:

The text box on the main forms Control Source should look like this:

=IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName] Is
Null,"ValueYouWant")

Hope this helps

On Mon, 10 Jan 2005 14:01:05 -0800, "Frankie"

I have a form with a subform : on the form there is a control (textbox)
wich
value should depend upon the checking of another control 's value
that's
located on the subform (If the value is Null then value1otherwise
value2). I
think the IIf function is the one to use but I can't get it to work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance

Thanks to both of you for your help.
I am still confused :
A-your solution seems to differ
B- When I write either one (as code) in the BeforeUpdate event of the
textbox [Etat] of main form [F_Interimaires] I keep getting syntax error
Here is what I put within Private Sub procedure:
Penguin proposal -IIf([Forms]![F_Interimaires]![Etat].[Form]![IDContrat]
IsNull,"Candidat","Interimaire")
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
Is there something I should add within Private Sub like a Call function
and if so how do I write it ??
Also, I am based in Paris so please take the time difference into account
when expecting an answer from me .
Waiting to read from you soon


Since [Etat] is bound to a table I opted for AfterUpdate Event on
[IDContrat] on subform with your solution or Tina's. The problem is that it
still does not work and I really don't get it!!!
The subform is used on another form, could that make a difference ??
Thanks for your continuing support


Tina,
The subform [F_FicheContrat sous-formulaire] is used on 2 main forms
[F_Interimaires] and [F_SuivimodMission].
It is set to "read only" on [F_Interimaires] (no mod, no add etc..) and
open to mod and addition on [F_SuiviModMission]. This subform has been
created first within [F_SuiviModMission ].
Also, the main form [F_Interimaires] has another subform in addition to
[F_FicheContrat sous-formulaire].
Hope this helps.

Hope this help
 
A

AlCamp

Frankie,
I tested my last solution...
If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If
on a test database I have (using the same concept with my names and
controls), and it worked fine. In the subform, when I changed the
[IDContrat] value, a bound field on the main form "reflected" those changes.
So... there may be something missing from your explanantion of your
"setup."
hth
Al Camp

Frankie said:
AlCamp said:
Frankie,
You wrote...
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
(You are missing a right bracket on [IDContrat].)

I don't think Penguin's solution will work, I've never seen the
IsNull
function expressed that way, and as far as I know, every IIF syntax must
denote a True and False...
IIf(expr, truepart, falsepart)
I haven't tested his solution... my apoplogies if I'm mistaken

The IIF calculation I posted is meant to be the Control Source of an
unbound field on the main form. Since IDContrat (null or not) always
determines Candidat or Interimaire, it is not necessary to save that
calculation in [Etat]... you just always "display" the calculation on the
main form.
In other words, since you always have IDContrat, you can always
recalculate Etat "on the fly".

Now, if you must save "Candidat" or "Interimaire" in [Etat] in your
table, then "bind" [Etat] to the Etat field, and use the AfterUpdate
event
of IDContrat itself with this code...

If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If

will update the field with the correct value.

hth
Al Camp

Frankie said:
:

The text box on the main forms Control Source should look like this:

=IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName] Is
Null,"ValueYouWant")

Hope this helps

On Mon, 10 Jan 2005 14:01:05 -0800, "Frankie"

I have a form with a subform : on the form there is a control
(textbox)
wich
value should depend upon the checking of another control 's value
that's
located on the subform (If the value is Null then value1otherwise
value2). I
think the IIf function is the one to use but I can't get it to work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance

Thanks to both of you for your help.
I am still confused :
A-your solution seems to differ
B- When I write either one (as code) in the BeforeUpdate event of the
textbox [Etat] of main form [F_Interimaires] I keep getting syntax
error
Here is what I put within Private Sub procedure:
Penguin
proposal -IIf([Forms]![F_Interimaires]![Etat].[Form]![IDContrat]
IsNull,"Candidat","Interimaire")
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
Is there something I should add within Private Sub like a Call
function
and if so how do I write it ??
Also, I am based in Paris so please take the time difference into
account
when expecting an answer from me .
Waiting to read from you soon


Since [Etat] is bound to a table I opted for AfterUpdate Event on
[IDContrat] on subform with your solution or Tina's. The problem is that
it still does not work and I really don't get it!!!
The subform is used on another form, could that make a difference ??
Thanks for your continuing support
 
G

Guest

AlCamp said:
Frankie,
I tested my last solution...
If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If
on a test database I have (using the same concept with my names and
controls), and it worked fine. In the subform, when I changed the
[IDContrat] value, a bound field on the main form "reflected" those changes.
So... there may be something missing from your explanantion of your
"setup."
hth
Al Camp

Frankie said:
AlCamp said:
Frankie,
You wrote...
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
(You are missing a right bracket on [IDContrat].)

I don't think Penguin's solution will work, I've never seen the
IsNull
function expressed that way, and as far as I know, every IIF syntax must
denote a True and False...
IIf(expr, truepart, falsepart)
I haven't tested his solution... my apoplogies if I'm mistaken

The IIF calculation I posted is meant to be the Control Source of an
unbound field on the main form. Since IDContrat (null or not) always
determines Candidat or Interimaire, it is not necessary to save that
calculation in [Etat]... you just always "display" the calculation on the
main form.
In other words, since you always have IDContrat, you can always
recalculate Etat "on the fly".

Now, if you must save "Candidat" or "Interimaire" in [Etat] in your
table, then "bind" [Etat] to the Etat field, and use the AfterUpdate
event
of IDContrat itself with this code...

If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If

will update the field with the correct value.

hth
Al Camp



:

The text box on the main forms Control Source should look like this:

=IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName] Is
Null,"ValueYouWant")

Hope this helps

On Mon, 10 Jan 2005 14:01:05 -0800, "Frankie"

I have a form with a subform : on the form there is a control
(textbox)
wich
value should depend upon the checking of another control 's value
that's
located on the subform (If the value is Null then value1otherwise
value2). I
think the IIf function is the one to use but I can't get it to work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance

Thanks to both of you for your help.
I am still confused :
A-your solution seems to differ
B- When I write either one (as code) in the BeforeUpdate event of the
textbox [Etat] of main form [F_Interimaires] I keep getting syntax
error
Here is what I put within Private Sub procedure:
Penguin
proposal -IIf([Forms]![F_Interimaires]![Etat].[Form]![IDContrat]
IsNull,"Candidat","Interimaire")
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
Is there something I should add within Private Sub like a Call
function
and if so how do I write it ??
Also, I am based in Paris so please take the time difference into
account
when expecting an answer from me .
Waiting to read from you soon


Since [Etat] is bound to a table I opted for AfterUpdate Event on
[IDContrat] on subform with your solution or Tina's. The problem is that
it still does not work and I really don't get it!!!
The subform is used on another form, could that make a difference ??
Thanks for your continuing support


It does work !!
Tha
 
G

Guest

AlCamp said:
Frankie,
I tested my last solution...
If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If
on a test database I have (using the same concept with my names and
controls), and it worked fine. In the subform, when I changed the
[IDContrat] value, a bound field on the main form "reflected" those changes.
So... there may be something missing from your explanantion of your
"setup."
hth
Al Camp

Frankie said:
AlCamp said:
Frankie,
You wrote...
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
(You are missing a right bracket on [IDContrat].)

I don't think Penguin's solution will work, I've never seen the
IsNull
function expressed that way, and as far as I know, every IIF syntax must
denote a True and False...
IIf(expr, truepart, falsepart)
I haven't tested his solution... my apoplogies if I'm mistaken

The IIF calculation I posted is meant to be the Control Source of an
unbound field on the main form. Since IDContrat (null or not) always
determines Candidat or Interimaire, it is not necessary to save that
calculation in [Etat]... you just always "display" the calculation on the
main form.
In other words, since you always have IDContrat, you can always
recalculate Etat "on the fly".

Now, if you must save "Candidat" or "Interimaire" in [Etat] in your
table, then "bind" [Etat] to the Etat field, and use the AfterUpdate
event
of IDContrat itself with this code...

If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If

will update the field with the correct value.

hth
Al Camp



:

The text box on the main forms Control Source should look like this:

=IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName] Is
Null,"ValueYouWant")

Hope this helps

On Mon, 10 Jan 2005 14:01:05 -0800, "Frankie"

I have a form with a subform : on the form there is a control
(textbox)
wich
value should depend upon the checking of another control 's value
that's
located on the subform (If the value is Null then value1otherwise
value2). I
think the IIf function is the one to use but I can't get it to work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance

Thanks to both of you for your help.
I am still confused :
A-your solution seems to differ
B- When I write either one (as code) in the BeforeUpdate event of the
textbox [Etat] of main form [F_Interimaires] I keep getting syntax
error
Here is what I put within Private Sub procedure:
Penguin
proposal -IIf([Forms]![F_Interimaires]![Etat].[Form]![IDContrat]
IsNull,"Candidat","Interimaire")
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
Is there something I should add within Private Sub like a Call
function
and if so how do I write it ??
Also, I am based in Paris so please take the time difference into
account
when expecting an answer from me .
Waiting to read from you soon


Since [Etat] is bound to a table I opted for AfterUpdate Event on
[IDContrat] on subform with your solution or Tina's. The problem is that
it still does not work and I really don't get it!!!
The subform is used on another form, could that make a difference ??
Thanks for your continuing support


It does work !!
Thank you for your help.
 
T

tina

okay, using the subform on two different main forms, and on main form
F_Interimaires, the subform is read-only. both important pieces of the
puzzle. i have to wonder why you're changing a value in the main form record
from a read-only value in the subform, but we'll go with that.

since you're not changing the value in the control on the subform, using the
AfterUpdate event won't work. instead, try adding the following code to the
subform's Current event procedure, as

If Me.Parent.Name = "F_Interimaires" Then
If IsNull(Me!IDContrat) Then
Me.Parent!Etat = "Candidat"
Else
Me.Parent!Etat = "Interimaire"
End If
End If

the above code checks to see if the subform is open in main form
F_Interimaires. if it is, then the update to textbox Etat takes place. if
instead the subform is open in main form F_SuiviModMission, then the update
will not take place.

since the update code runs from the subform's Current event, you also need
to consider the following: are there multiple records in the subform? do i
want the value in Etat to be changed each time i move between multiple
records on the subform? once the value has been set in Etat, do i want it to
be changed every time i move between records on the main form? every time i
open the main form?

the last two things mentioned above *will* happen automatically, whether the
subform has one or multiple records, unless you write code to stop it. you
have to figure out exactly what you want to happen, and when, in order to
control the situation.

hth


Frankie said:
tina said:
The subform is used on another form, could that make a difference ??

do you mean the subform is used on another main form *in addition to* form
F_Interimaires? or another main form *instead of* form F_Interimaires?

please explain your setup in a little more depth.


Frankie said:
:

Frankie,
You wrote...
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
(You are missing a right bracket on [IDContrat].)

I don't think Penguin's solution will work, I've never seen the IsNull
function expressed that way, and as far as I know, every IIF syntax must
denote a True and False...
IIf(expr, truepart, falsepart)
I haven't tested his solution... my apoplogies if I'm mistaken

The IIF calculation I posted is meant to be the Control Source of an
unbound field on the main form. Since IDContrat (null or not) always
determines Candidat or Interimaire, it is not necessary to save that
calculation in [Etat]... you just always "display" the calculation
on
the
main form.
In other words, since you always have IDContrat, you can always
recalculate Etat "on the fly".

Now, if you must save "Candidat" or "Interimaire" in [Etat] in your
table, then "bind" [Etat] to the Etat field, and use the AfterUpdate event
of IDContrat itself with this code...

If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If

will update the field with the correct value.

hth
Al Camp



:

The text box on the main forms Control Source should look like this:

=IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName] Is
Null,"ValueYouWant")

Hope this helps

On Mon, 10 Jan 2005 14:01:05 -0800, "Frankie"

I have a form with a subform : on the form there is a control (textbox)
wich
value should depend upon the checking of another control 's value
that's
located on the subform (If the value is Null then value1otherwise
value2). I
think the IIf function is the one to use but I can't get it to work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance

Thanks to both of you for your help.
I am still confused :
A-your solution seems to differ
B- When I write either one (as code) in the BeforeUpdate event of the
textbox [Etat] of main form [F_Interimaires] I keep getting syntax error
Here is what I put within Private Sub procedure:
Penguin
proposal -IIf([Forms]![F_Interimaires]![Etat].[Form]![IDContrat]
IsNull,"Candidat","Interimaire")
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
Is there something I should add within Private Sub like a Call function
and if so how do I write it ??
Also, I am based in Paris so please take the time difference into account
when expecting an answer from me .
Waiting to read from you soon


Since [Etat] is bound to a table I opted for AfterUpdate Event
on
[IDContrat] on subform with your solution or Tina's. The problem is that it
still does not work and I really don't get it!!!
The subform is used on another form, could that make a difference ??
Thanks for your continuing support


Tina,
The subform [F_FicheContrat sous-formulaire] is used on 2 main forms
[F_Interimaires] and [F_SuivimodMission].
It is set to "read only" on [F_Interimaires] (no mod, no add etc..) and
open to mod and addition on [F_SuiviModMission]. This subform has been
created first within [F_SuiviModMission ].
Also, the main form [F_Interimaires] has another subform in addition to
[F_FicheContrat sous-formulaire].
Hope this helps.

Hope this help
 
G

Guest

tina said:
okay, using the subform on two different main forms, and on main form
F_Interimaires, the subform is read-only. both important pieces of the
puzzle. i have to wonder why you're changing a value in the main form record
from a read-only value in the subform, but we'll go with that.

since you're not changing the value in the control on the subform, using the
AfterUpdate event won't work. instead, try adding the following code to the
subform's Current event procedure, as

If Me.Parent.Name = "F_Interimaires" Then
If IsNull(Me!IDContrat) Then
Me.Parent!Etat = "Candidat"
Else
Me.Parent!Etat = "Interimaire"
End If
End If

the above code checks to see if the subform is open in main form
F_Interimaires. if it is, then the update to textbox Etat takes place. if
instead the subform is open in main form F_SuiviModMission, then the update
will not take place.

since the update code runs from the subform's Current event, you also need
to consider the following: are there multiple records in the subform? do i
want the value in Etat to be changed each time i move between multiple
records on the subform? once the value has been set in Etat, do i want it to
be changed every time i move between records on the main form? every time i
open the main form?

the last two things mentioned above *will* happen automatically, whether the
subform has one or multiple records, unless you write code to stop it. you
have to figure out exactly what you want to happen, and when, in order to
control the situation.

hth


Frankie said:
tina said:
The subform is used on another form, could that make a difference ??

do you mean the subform is used on another main form *in addition to* form
F_Interimaires? or another main form *instead of* form F_Interimaires?

please explain your setup in a little more depth.




:

Frankie,
You wrote...
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
(You are missing a right bracket on [IDContrat].)

I don't think Penguin's solution will work, I've never seen the
IsNull
function expressed that way, and as far as I know, every IIF syntax must
denote a True and False...
IIf(expr, truepart, falsepart)
I haven't tested his solution... my apoplogies if I'm mistaken

The IIF calculation I posted is meant to be the Control Source of an
unbound field on the main form. Since IDContrat (null or not) always
determines Candidat or Interimaire, it is not necessary to save that
calculation in [Etat]... you just always "display" the calculation on
the
main form.
In other words, since you always have IDContrat, you can always
recalculate Etat "on the fly".

Now, if you must save "Candidat" or "Interimaire" in [Etat] in your
table, then "bind" [Etat] to the Etat field, and use the AfterUpdate
event
of IDContrat itself with this code...

If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If

will update the field with the correct value.

hth
Al Camp



:

The text box on the main forms Control Source should look like this:

=IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName] Is
Null,"ValueYouWant")

Hope this helps

On Mon, 10 Jan 2005 14:01:05 -0800, "Frankie"

I have a form with a subform : on the form there is a control
(textbox)
wich
value should depend upon the checking of another control 's value
that's
located on the subform (If the value is Null then value1otherwise
value2). I
think the IIf function is the one to use but I can't get it to work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance

Thanks to both of you for your help.
I am still confused :
A-your solution seems to differ
B- When I write either one (as code) in the BeforeUpdate event of the
textbox [Etat] of main form [F_Interimaires] I keep getting syntax
error
Here is what I put within Private Sub procedure:
Penguin
proposal -IIf([Forms]![F_Interimaires]![Etat].[Form]![IDContrat]
IsNull,"Candidat","Interimaire")
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
Is there something I should add within Private Sub like a Call
function
and if so how do I write it ??
Also, I am based in Paris so please take the time difference into
account
when expecting an answer from me .
Waiting to read from you soon


Since [Etat] is bound to a table I opted for AfterUpdate Event on
[IDContrat] on subform with your solution or Tina's. The problem is that it
still does not work and I really don't get it!!!
The subform is used on another form, could that make a difference ??
Thanks for your continuing support



Tina,
The subform [F_FicheContrat sous-formulaire] is used on 2 main forms
[F_Interimaires] and [F_SuivimodMission].
It is set to "read only" on [F_Interimaires] (no mod, no add etc..) and
open to mod and addition on [F_SuiviModMission]. This subform has been
created first within [F_SuiviModMission ].
Also, the main form [F_Interimaires] has another subform in addition to
[F_FicheContrat sous-formulaire].
Hope this helps.

Hope this help


Tina,
As you may have noticed I 'm not an expert with Access VBA code.
This project I'm working on is getting to a point where good code writing
becomes essential to make the whole database run smoothly.
Project detail :
Development of DB for Temporary jobs Agency activities including prospects
management, Temp WorKers management , Sales force management.
I have built all the necessary forms and tables with all kind of queries and
put fake data to make some tests.
For example, the main form [F_Interimaires] contains all kind of info which
relate to the temporary workers in search of Temp jobs.
The main form [F_SuiviModMissions] contains info about "Missions' meaning
temporary job positions to be filled in a determined area.
In order to avoid "doublons" (same lenghty infos on multiple fomrs) I first
created the subform [F_FicheContrat sous-formulaire] from the main form
[F_SuiviModMission] bound on [IDMission] control box with [IDContrat] set as
autonum field. So when a Temp Worker qualifies for a given mission, the
[IDContat] increments as soon as a TW is choosen from a listbox
[IDInterimaire]
Now, what I want to see happening is : as soon as contract number gets
created for any given TW (Interimaire), the status of [Etat] on main form
[F_Interimaires] wich is by default "Candidat" should change to
"Interimaire". And I thought that by putting subform [F_FicheContrat
sous-formulaire] in "read-only" within main form [F_Interimaires] I could
create a conditional value to [Etat] control box.
Again I am no expert and I need to learn code writing if I want to achieve
this DB which I do. And I have a lot of conditional values to set on
different forms.
I figure that if manage to do it the right way for one then I 'll be able to
replicate it. Or am i just overestimating myself???
I hope this gives you a better idea...
 
T

tina

i'm afraid you really lost me, Frankie (though i'll readily admit that i'm
not as good as many folks here at visualizing a setup from a written
description).
I have built all the necessary forms and tables

this statement gives me a bit of a chill, though. proper database design is
to build and relate normalized tables *first*, and then the queries, forms,
etc, will flow logically from that foundation. how about posting your
tables/ relationships setup, in the following type of outline:

tblCustomers
CustID (primary key, called PK)
CustFirstName
CustLastName
etc.

tblOrders
OrderID (PK)
CustID (foreign key from tblCustomers)
OrderDate
etc

tblOrderDetails
OrdDetailID (PK)
OrderID (foreign key from tblOrders)
ProductID (foreign key from tblProducts)
Quantity
etc.

tblProducts
ProductID (PK)
Product Name
etc

tblCustomers [one-to-many] tblOrders
tblOrders [one-to-many] tblOrderDetails
tblProducts [one-to-many] tblOrderDetails


Frankie said:
tina said:
okay, using the subform on two different main forms, and on main form
F_Interimaires, the subform is read-only. both important pieces of the
puzzle. i have to wonder why you're changing a value in the main form record
from a read-only value in the subform, but we'll go with that.

since you're not changing the value in the control on the subform, using the
AfterUpdate event won't work. instead, try adding the following code to the
subform's Current event procedure, as

If Me.Parent.Name = "F_Interimaires" Then
If IsNull(Me!IDContrat) Then
Me.Parent!Etat = "Candidat"
Else
Me.Parent!Etat = "Interimaire"
End If
End If

the above code checks to see if the subform is open in main form
F_Interimaires. if it is, then the update to textbox Etat takes place. if
instead the subform is open in main form F_SuiviModMission, then the update
will not take place.

since the update code runs from the subform's Current event, you also need
to consider the following: are there multiple records in the subform? do i
want the value in Etat to be changed each time i move between multiple
records on the subform? once the value has been set in Etat, do i want it to
be changed every time i move between records on the main form? every time i
open the main form?

the last two things mentioned above *will* happen automatically, whether the
subform has one or multiple records, unless you write code to stop it. you
have to figure out exactly what you want to happen, and when, in order to
control the situation.

hth


Frankie said:
:

The subform is used on another form, could that make a difference ??

do you mean the subform is used on another main form *in addition
to*
form
F_Interimaires? or another main form *instead of* form F_Interimaires?

please explain your setup in a little more depth.




:

Frankie,
You wrote...
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
(You are missing a right bracket on [IDContrat].)

I don't think Penguin's solution will work, I've never seen the
IsNull
function expressed that way, and as far as I know, every IIF
syntax
must
denote a True and False...
IIf(expr, truepart, falsepart)
I haven't tested his solution... my apoplogies if I'm mistaken

The IIF calculation I posted is meant to be the Control
Source
of an
unbound field on the main form. Since IDContrat (null or not) always
determines Candidat or Interimaire, it is not necessary to save that
calculation in [Etat]... you just always "display" the
calculation
on
the
main form.
In other words, since you always have IDContrat, you can always
recalculate Etat "on the fly".

Now, if you must save "Candidat" or "Interimaire" in [Etat]
in
your
table, then "bind" [Etat] to the Etat field, and use the AfterUpdate
event
of IDContrat itself with this code...

If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If

will update the field with the correct value.

hth
Al Camp



:

The text box on the main forms Control Source should look
like
this: =IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName]
Is
Null,"ValueYouWant")

Hope this helps

On Mon, 10 Jan 2005 14:01:05 -0800, "Frankie"

I have a form with a subform : on the form there is a control
(textbox)
wich
value should depend upon the checking of another control 's value
that's
located on the subform (If the value is Null then value1otherwise
value2). I
think the IIf function is the one to use but I can't get it
to
work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance

Thanks to both of you for your help.
I am still confused :
A-your solution seems to differ
B- When I write either one (as code) in the BeforeUpdate event
of
the
textbox [Etat] of main form [F_Interimaires] I keep getting syntax
error
Here is what I put within Private Sub procedure:
Penguin
proposal -IIf([Forms]![F_Interimaires]![Etat].[Form]![IDContrat]
IsNull,"Candidat","Interimaire")
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
Is there something I should add within Private Sub like a Call
function
and if so how do I write it ??
Also, I am based in Paris so please take the time difference into
account
when expecting an answer from me .
Waiting to read from you soon


Since [Etat] is bound to a table I opted for AfterUpdate
Event
on
[IDContrat] on subform with your solution or Tina's. The problem is that it
still does not work and I really don't get it!!!
The subform is used on another form, could that make a difference ??
Thanks for your continuing support



Tina,
The subform [F_FicheContrat sous-formulaire] is used on 2 main forms
[F_Interimaires] and [F_SuivimodMission].
It is set to "read only" on [F_Interimaires] (no mod, no add etc..) and
open to mod and addition on [F_SuiviModMission]. This subform has been
created first within [F_SuiviModMission ].
Also, the main form [F_Interimaires] has another subform in addition to
[F_FicheContrat sous-formulaire].
Hope this helps.

Hope this help


Tina,
As you may have noticed I 'm not an expert with Access VBA code.
This project I'm working on is getting to a point where good code writing
becomes essential to make the whole database run smoothly.
Project detail :
Development of DB for Temporary jobs Agency activities including prospects
management, Temp WorKers management , Sales force management.
I have built all the necessary forms and tables with all kind of queries and
put fake data to make some tests.
For example, the main form [F_Interimaires] contains all kind of info which
relate to the temporary workers in search of Temp jobs.
The main form [F_SuiviModMissions] contains info about "Missions' meaning
temporary job positions to be filled in a determined area.
In order to avoid "doublons" (same lenghty infos on multiple fomrs) I first
created the subform [F_FicheContrat sous-formulaire] from the main form
[F_SuiviModMission] bound on [IDMission] control box with [IDContrat] set as
autonum field. So when a Temp Worker qualifies for a given mission, the
[IDContat] increments as soon as a TW is choosen from a listbox
[IDInterimaire]
Now, what I want to see happening is : as soon as contract number gets
created for any given TW (Interimaire), the status of [Etat] on main form
[F_Interimaires] wich is by default "Candidat" should change to
"Interimaire". And I thought that by putting subform [F_FicheContrat
sous-formulaire] in "read-only" within main form [F_Interimaires] I could
create a conditional value to [Etat] control box.
Again I am no expert and I need to learn code writing if I want to achieve
this DB which I do. And I have a lot of conditional values to set on
different forms.
I figure that if manage to do it the right way for one then I 'll be able to
replicate it. Or am i just overestimating myself???
I hope this gives you a better idea...
 
G

Guest

tina said:
i'm afraid you really lost me, Frankie (though i'll readily admit that i'm
not as good as many folks here at visualizing a setup from a written
description).
I have built all the necessary forms and tables

this statement gives me a bit of a chill, though. proper database design is
to build and relate normalized tables *first*, and then the queries, forms,
etc, will flow logically from that foundation. how about posting your
tables/ relationships setup, in the following type of outline:

tblCustomers
CustID (primary key, called PK)
CustFirstName
CustLastName
etc.

tblOrders
OrderID (PK)
CustID (foreign key from tblCustomers)
OrderDate
etc

tblOrderDetails
OrdDetailID (PK)
OrderID (foreign key from tblOrders)
ProductID (foreign key from tblProducts)
Quantity
etc.

tblProducts
ProductID (PK)
Product Name
etc

tblCustomers [one-to-many] tblOrders
tblOrders [one-to-many] tblOrderDetails
tblProducts [one-to-many] tblOrderDetails


Frankie said:
tina said:
okay, using the subform on two different main forms, and on main form
F_Interimaires, the subform is read-only. both important pieces of the
puzzle. i have to wonder why you're changing a value in the main form record
from a read-only value in the subform, but we'll go with that.

since you're not changing the value in the control on the subform, using the
AfterUpdate event won't work. instead, try adding the following code to the
subform's Current event procedure, as

If Me.Parent.Name = "F_Interimaires" Then
If IsNull(Me!IDContrat) Then
Me.Parent!Etat = "Candidat"
Else
Me.Parent!Etat = "Interimaire"
End If
End If

the above code checks to see if the subform is open in main form
F_Interimaires. if it is, then the update to textbox Etat takes place. if
instead the subform is open in main form F_SuiviModMission, then the update
will not take place.

since the update code runs from the subform's Current event, you also need
to consider the following: are there multiple records in the subform? do i
want the value in Etat to be changed each time i move between multiple
records on the subform? once the value has been set in Etat, do i want it to
be changed every time i move between records on the main form? every time i
open the main form?

the last two things mentioned above *will* happen automatically, whether the
subform has one or multiple records, unless you write code to stop it. you
have to figure out exactly what you want to happen, and when, in order to
control the situation.

hth




:

The subform is used on another form, could that make a difference ??

do you mean the subform is used on another main form *in addition to*
form
F_Interimaires? or another main form *instead of* form F_Interimaires?

please explain your setup in a little more depth.




:

Frankie,
You wrote...
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
(You are missing a right bracket on [IDContrat].)

I don't think Penguin's solution will work, I've never seen the
IsNull
function expressed that way, and as far as I know, every IIF syntax
must
denote a True and False...
IIf(expr, truepart, falsepart)
I haven't tested his solution... my apoplogies if I'm mistaken

The IIF calculation I posted is meant to be the Control Source
of an
unbound field on the main form. Since IDContrat (null or not)
always
determines Candidat or Interimaire, it is not necessary to save that
calculation in [Etat]... you just always "display" the calculation
on
the
main form.
In other words, since you always have IDContrat, you can always
recalculate Etat "on the fly".

Now, if you must save "Candidat" or "Interimaire" in [Etat] in
your
table, then "bind" [Etat] to the Etat field, and use the AfterUpdate
event
of IDContrat itself with this code...

If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If

will update the field with the correct value.

hth
Al Camp



:

The text box on the main forms Control Source should look like
this:

=IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName]
Is
Null,"ValueYouWant")

Hope this helps

On Mon, 10 Jan 2005 14:01:05 -0800, "Frankie"

I have a form with a subform : on the form there is a control
(textbox)
wich
value should depend upon the checking of another control 's
value
that's
located on the subform (If the value is Null then
value1otherwise
value2). I
think the IIf function is the one to use but I can't get it to
work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance

Thanks to both of you for your help.
I am still confused :
A-your solution seems to differ
B- When I write either one (as code) in the BeforeUpdate event of
the
textbox [Etat] of main form [F_Interimaires] I keep getting syntax
error
Here is what I put within Private Sub procedure:
Penguin
proposal -IIf([Forms]![F_Interimaires]![Etat].[Form]![IDContrat]
IsNull,"Candidat","Interimaire")
Al proposal -
=IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
Is there something I should add within Private Sub like a Call
function
and if so how do I write it ??
Also, I am based in Paris so please take the time difference into
account
when expecting an answer from me .
Waiting to read from you soon


Since [Etat] is bound to a table I opted for AfterUpdate Event
on
[IDContrat] on subform with your solution or Tina's. The problem is
that it
still does not work and I really don't get it!!!
The subform is used on another form, could that make a difference ??
Thanks for your continuing support



Tina,
The subform [F_FicheContrat sous-formulaire] is used on 2 main forms
[F_Interimaires] and [F_SuivimodMission].
It is set to "read only" on [F_Interimaires] (no mod, no add etc..) and
open to mod and addition on [F_SuiviModMission]. This subform has been
created first within [F_SuiviModMission ].
Also, the main form [F_Interimaires] has another subform in addition to
[F_FicheContrat sous-formulaire].
Hope this helps.

Hope this help



Tina,
As you may have noticed I 'm not an expert with Access VBA code.
This project I'm working on is getting to a point where good code writing
becomes essential to make the whole database run smoothly.
Project detail :
Development of DB for Temporary jobs Agency activities including prospects
management, Temp WorKers management , Sales force management.
I have built all the necessary forms and tables with all kind of queries and
put fake data to make some tests.
For example, the main form [F_Interimaires] contains all kind of info which
relate to the temporary workers in search of Temp jobs.
The main form [F_SuiviModMissions] contains info about "Missions' meaning
temporary job positions to be filled in a determined area.
In order to avoid "doublons" (same lenghty infos on multiple fomrs) I first
created the subform [F_FicheContrat sous-formulaire] from the main form
[F_SuiviModMission] bound on [IDMission] control box with [IDContrat] set as
autonum field. So when a Temp Worker qualifies for a given mission, the
[IDContat] increments as soon as a TW is choosen from a listbox
[IDInterimaire]
Now, what I want to see happening is : as soon as contract number gets
created for any given TW (Interimaire), the status of [Etat] on main form
[F_Interimaires] wich is by default "Candidat" should change to
"Interimaire". And I thought that by putting subform [F_FicheContrat
sous-formulaire] in "read-only" within main form [F_Interimaires] I could
create a conditional value to [Etat] control box.
Again I am no expert and I need to learn code writing if I want to achieve
this DB which I do. And I have a lot of conditional values to set on
different forms.
I figure that if manage to do it the right way for one then I 'll be able to
replicate it. Or am i just overestimating myself???
I hope this gives you a better idea...


Tina,
Here is my table/relationships setup :

tblInterimaires (Temp Workers)
IDInterimaires (PK)
FirstName
LastName
Departement
Acticity
etc.

tblClients (Prospects/Customers)
IDClients (PK)
FirstName
LastName
etc.

tblMissions
IDMissions (PK)
IDClients (foreign key to tblClients)
Departement
Activity
etc.

tblContrats
IDContrat (PK)
IDMissions (foreign key to tblMissions)
IDInterimaire (foreign key to tblInterimaires)

tblCommercial (Sales Force)
IDCommercial (PK)
FirstName
LastName
etc.

tblSuiviCommercial (Prospects follow up)
IDSuivi (PK)
IDCommercial (foreign key to tblCommercial)
IDClients (foreign key to tblClients)
etc;

tblCRH (Contracts Hours )
IDCRH (PK)
IDContrat (foreign key to tblContrat)

tbl Interimaires [one-to-many] tblContrat
tblClients [one-to-many] tblMissions
tblMissions [one-to-many] tblContrat
tblCommerciaux [one-to-many] tblSuiviCommercial
tblClients [one-to-many] tblsuiviCommercial
tblContrat [one-to-many] tblCRH
 
T

tina

okay, just what i needed. i'll have to study this a bit, and try to apply it
to your forms question. one way or another, i'll post back to you within a
day.


Frankie said:
tina said:
i'm afraid you really lost me, Frankie (though i'll readily admit that i'm
not as good as many folks here at visualizing a setup from a written
description).
I have built all the necessary forms and tables

this statement gives me a bit of a chill, though. proper database design is
to build and relate normalized tables *first*, and then the queries, forms,
etc, will flow logically from that foundation. how about posting your
tables/ relationships setup, in the following type of outline:

tblCustomers
CustID (primary key, called PK)
CustFirstName
CustLastName
etc.

tblOrders
OrderID (PK)
CustID (foreign key from tblCustomers)
OrderDate
etc

tblOrderDetails
OrdDetailID (PK)
OrderID (foreign key from tblOrders)
ProductID (foreign key from tblProducts)
Quantity
etc.

tblProducts
ProductID (PK)
Product Name
etc

tblCustomers [one-to-many] tblOrders
tblOrders [one-to-many] tblOrderDetails
tblProducts [one-to-many] tblOrderDetails


Frankie said:
:

okay, using the subform on two different main forms, and on main form
F_Interimaires, the subform is read-only. both important pieces of the
puzzle. i have to wonder why you're changing a value in the main
form
record
from a read-only value in the subform, but we'll go with that.

since you're not changing the value in the control on the subform,
using
the
AfterUpdate event won't work. instead, try adding the following code
to
the
subform's Current event procedure, as

If Me.Parent.Name = "F_Interimaires" Then
If IsNull(Me!IDContrat) Then
Me.Parent!Etat = "Candidat"
Else
Me.Parent!Etat = "Interimaire"
End If
End If

the above code checks to see if the subform is open in main form
F_Interimaires. if it is, then the update to textbox Etat takes
place.
if
instead the subform is open in main form F_SuiviModMission, then the update
will not take place.

since the update code runs from the subform's Current event, you
also
need
to consider the following: are there multiple records in the
subform?
do i
want the value in Etat to be changed each time i move between multiple
records on the subform? once the value has been set in Etat, do i
want
it to
be changed every time i move between records on the main form? every time i
open the main form?

the last two things mentioned above *will* happen automatically,
whether
the
subform has one or multiple records, unless you write code to stop
it.
you
have to figure out exactly what you want to happen, and when, in
order
to
control the situation.

hth




:

The subform is used on another form, could that make a
difference
??
do you mean the subform is used on another main form *in
addition
to*
form
F_Interimaires? or another main form *instead of* form F_Interimaires?

please explain your setup in a little more depth.




:

Frankie,
You wrote...
Al proposal - =IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
(You are missing a right bracket on [IDContrat].)

I don't think Penguin's solution will work, I've never
seen
the
IsNull
function expressed that way, and as far as I know, every IIF syntax
must
denote a True and False...
IIf(expr, truepart, falsepart)
I haven't tested his solution... my apoplogies if I'm mistaken

The IIF calculation I posted is meant to be the Control Source
of an
unbound field on the main form. Since IDContrat (null or not)
always
determines Candidat or Interimaire, it is not necessary to
save
that
calculation in [Etat]... you just always "display" the calculation
on
the
main form.
In other words, since you always have IDContrat, you can always
recalculate Etat "on the fly".

Now, if you must save "Candidat" or "Interimaire" in
[Etat]
in
your
table, then "bind" [Etat] to the Etat field, and use the AfterUpdate
event
of IDContrat itself with this code...

If IsNull(IDContrat) Then
[Forms]![F_Interimaires]![Etat] = "Candidat"
Else
[Forms]![F_Interimaires]![Etat] = "Interimaire"
End If

will update the field with the correct value.

hth
Al Camp



:

The text box on the main forms Control Source should look like
=IIf([Forms]![FormName]![ControlName].[Form]![SubFormControlName]
Is
Null,"ValueYouWant")

Hope this helps

On Mon, 10 Jan 2005 14:01:05 -0800, "Frankie"

I have a form with a subform : on the form there is a control
(textbox)
wich
value should depend upon the checking of another control 's
value
that's
located on the subform (If the value is Null then
value1otherwise
value2). I
think the IIf function is the one to use but I can't get
it
to
work.
I have also tried the If....Then...esle to no avail.
Can someone please help me with the best way to do it. ??
Version : Access 2002
Thanks in advance

Thanks to both of you for your help.
I am still confused :
A-your solution seems to differ
B- When I write either one (as code) in the BeforeUpdate
event
of
the
textbox [Etat] of main form [F_Interimaires] I keep
getting
syntax
error
Here is what I put within Private Sub procedure:
Penguin
proposal -IIf([Forms]![F_Interimaires]![Etat].[Form]![IDContrat]
IsNull,"Candidat","Interimaire")
Al proposal -
=IIF(IsNull([Forms]![F_Interimaires]![F_FicheContrat
sous-formulaire].Form![IDContrat),"Candidat","Interimaire")
Is there something I should add within Private Sub like
a
Call
function
and if so how do I write it ??
Also, I am based in Paris so please take the time
difference
into
account
when expecting an answer from me .
Waiting to read from you soon


Since [Etat] is bound to a table I opted for AfterUpdate Event
on
[IDContrat] on subform with your solution or Tina's. The problem is
that it
still does not work and I really don't get it!!!
The subform is used on another form, could that make a
difference
??
Thanks for your continuing support



Tina,
The subform [F_FicheContrat sous-formulaire] is used on 2 main forms
[F_Interimaires] and [F_SuivimodMission].
It is set to "read only" on [F_Interimaires] (no mod, no add
etc..)
and
open to mod and addition on [F_SuiviModMission]. This subform has been
created first within [F_SuiviModMission ].
Also, the main form [F_Interimaires] has another subform in
addition
to
[F_FicheContrat sous-formulaire].
Hope this helps.

Hope this help



Tina,
As you may have noticed I 'm not an expert with Access VBA code.
This project I'm working on is getting to a point where good code writing
becomes essential to make the whole database run smoothly.
Project detail :
Development of DB for Temporary jobs Agency activities including prospects
management, Temp WorKers management , Sales force management.
I have built all the necessary forms and tables with all kind of
queries
and
put fake data to make some tests.
For example, the main form [F_Interimaires] contains all kind of info which
relate to the temporary workers in search of Temp jobs.
The main form [F_SuiviModMissions] contains info about "Missions' meaning
temporary job positions to be filled in a determined area.
In order to avoid "doublons" (same lenghty infos on multiple fomrs) I first
created the subform [F_FicheContrat sous-formulaire] from the main form
[F_SuiviModMission] bound on [IDMission] control box with [IDContrat]
set
as
autonum field. So when a Temp Worker qualifies for a given mission, the
[IDContat] increments as soon as a TW is choosen from a listbox
[IDInterimaire]
Now, what I want to see happening is : as soon as contract number gets
created for any given TW (Interimaire), the status of [Etat] on main form
[F_Interimaires] wich is by default "Candidat" should change to
"Interimaire". And I thought that by putting subform [F_FicheContrat
sous-formulaire] in "read-only" within main form [F_Interimaires] I could
create a conditional value to [Etat] control box.
Again I am no expert and I need to learn code writing if I want to achieve
this DB which I do. And I have a lot of conditional values to set on
different forms.
I figure that if manage to do it the right way for one then I 'll be
able
to
replicate it. Or am i just overestimating myself???
I hope this gives you a better idea...


Tina,
Here is my table/relationships setup :

tblInterimaires (Temp Workers)
IDInterimaires (PK)
FirstName
LastName
Departement
Acticity
etc.

tblClients (Prospects/Customers)
IDClients (PK)
FirstName
LastName
etc.

tblMissions
IDMissions (PK)
IDClients (foreign key to tblClients)
Departement
Activity
etc.

tblContrats
IDContrat (PK)
IDMissions (foreign key to tblMissions)
IDInterimaire (foreign key to tblInterimaires)

tblCommercial (Sales Force)
IDCommercial (PK)
FirstName
LastName
etc.

tblSuiviCommercial (Prospects follow up)
IDSuivi (PK)
IDCommercial (foreign key to tblCommercial)
IDClients (foreign key to tblClients)
etc;

tblCRH (Contracts Hours )
IDCRH (PK)
IDContrat (foreign key to tblContrat)

tbl Interimaires [one-to-many] tblContrat
tblClients [one-to-many] tblMissions
tblMissions [one-to-many] tblContrat
tblCommerciaux [one-to-many] tblSuiviCommercial
tblClients [one-to-many] tblsuiviCommercial
tblContrat [one-to-many] tblCRH
 
T

tina

okay, i think i'm beginning to get the picture. i'll guess that:

your main form F_SuiviModMission is bound to tblMissions (or bound to a
query that includes fields from tblMissions)
your subform F_FicheContrat sous-formulaire is bound to tblContrats

within main form F_SuiviModMission, in subform F_FicheContrat
sous-formulaire, you create new records in tblContrats by entering an
IDInterimaires value from tblInterimaires. in other words, you assigning a
temporary worker to a specific mission belonging to a specific client.

now, i'll assume that there is a field in tblInterimaires that shows the
current status of the temporary worker - either "Candidat" or "Interimaire".
(i'm guessing that more or less means "available for assignment" or
"currently assigned to a job".)

i'll also assume there are fields in tblContrats that hold the date a
particular job was assigned, and another date for when it was closed. or
perhaps a "Closed" checkbox. at any rate, *some value* in each record that
indicates whether the worker's assignment is current, or concluded.

given all the above assumptions, i would forget changing the status of the
worker's record from within main form F_Interimaires. instead, change the
status of the worker to "Interimaire" when the new record is added in
subform F_FicheContrat sous-formulaire, within main form F_SuiviModMission.
and then change the worker's status again when the contract is concluded.
you could do that with an update query, run on the subform's AfterUpdate
event, and referring to the value in field IDInterimaire to update the
correct record in tblInterimaires. something along the lines of

If Me!ClosedContract = False Then
CurrentDb.Execute "UPDATE tblInterimaires SET " _
& "WorkerStatus = 'Interimaires' WHERE IDInterimaires = " _
& Me!IDInterimaire, dbFailOnError
ElseIf Me!ClosedContract = True Then
CurrentDb.Execute "UPDATE tblInterimaires SET " _
& "WorkerStatus = 'Candidat' WHERE IDInterimaires = " _
& Me!IDInterimaire, dbFailOnError
End If

i made up the name WorkerStatus, of course, but the above should give you an
understanding of what i'm getting at. you can modify it to work in your
situation. you have to consider some possible situations here, such as:
once a contract record is created, can the IDInterimaire value be changed
(can you substitute Mary for Lisa, in an existing record)? if yes, you need
to write code to handle changing Lisa's status back to "Candidat", and
changing Mary's status to "Interimaire". once a contract record is created,
can it be deleted? or marked as "void"? in either case, you'd again have to
update the worker's status back to "Candidat".

hopefully my guesses are close enough to give you some ideas of how to
accomplish your task.


Frankie said:
Here is my table/relationships setup :

tblInterimaires (Temp Workers)
IDInterimaires (PK)
FirstName
LastName
Departement
Acticity
etc.

tblClients (Prospects/Customers)
IDClients (PK)
FirstName
LastName
etc.

tblMissions
IDMissions (PK)
IDClients (foreign key to tblClients)
Departement
Activity
etc.

tblContrats
IDContrat (PK)
IDMissions (foreign key to tblMissions)
IDInterimaire (foreign key to tblInterimaires)

tblCommercial (Sales Force)
IDCommercial (PK)
FirstName
LastName
etc.

tblSuiviCommercial (Prospects follow up)
IDSuivi (PK)
IDCommercial (foreign key to tblCommercial)
IDClients (foreign key to tblClients)
etc;

tblCRH (Contracts Hours )
IDCRH (PK)
IDContrat (foreign key to tblContrat)

tbl Interimaires [one-to-many] tblContrat
tblClients [one-to-many] tblMissions
tblMissions [one-to-many] tblContrat
tblCommerciaux [one-to-many] tblSuiviCommercial
tblClients [one-to-many] tblsuiviCommercial
tblContrat [one-to-many] tblCRH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top