IF... THEN... AND... on form exit

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a form with an embedded subform. I have added the following event on
the subform exit properties and it works:

If Subtotal_Rev_Adj_Loc_Cur = 0 Then Forms![2a Input Template Brussels Top
Line].[Closed On] = Now()

Now I tried to change it to this:
If Subtotal_Rev_Adj_Loc_Cur = 0 Then Forms![2a Input Template Brussels Top
Line].[Closed On] = Now() and Forms![2a Input Template Brussels Top
Line].[Closed By] = CurrentUser()

but nothing happens.

I tried each functions individully (now() and currentuser()) as a part of
then statement and they both work. But they don't work together.

I thought that using IF was rather straight forward: "if condition then
result1 and result2"

but I guess I'm doing something wrong. If anyone knows what it is I would
really appreciate your help.

Thanks a lot in advance.
 
If Subtotal_Rev_Adj_Loc_Cur = 0 Then Forms![2a Input Template Brussels Top
Line].[Closed On] = Now() and Forms![2a Input Template Brussels Top
Line].[Closed By] = CurrentUser()

if you wrote the code exactly as you show it above, then there's your
problem. you can use the "If...Then..." format when you only have one "Then"
action. otherwise, you need to use the following format, as

If Subtotal_Rev_Adj_Loc_Cur = 0 Then
Forms![2a Input Template Brussels Top Line].[Closed On] = Now
Forms![2a Input Template Brussels Top Line].[Closed By] =
CurrentUser
End If

each of the "instructions" after the If...Then line, need to be on a single
line (even though they may automatically wrap, in this post).

hth
 
Thank you so much Tina. This works perfectly now. I would have never thought
of this. This is awesome!

Thanks again.
Géraldine
 
you're welcome :)


Kanga said:
Thank you so much Tina. This works perfectly now. I would have never thought
of this. This is awesome!

Thanks again.
Géraldine

Kanga said:
Hi,

I have a form with an embedded subform. I have added the following event on
the subform exit properties and it works:

If Subtotal_Rev_Adj_Loc_Cur = 0 Then Forms![2a Input Template Brussels Top
Line].[Closed On] = Now()

Now I tried to change it to this:
If Subtotal_Rev_Adj_Loc_Cur = 0 Then Forms![2a Input Template Brussels Top
Line].[Closed On] = Now() and Forms![2a Input Template Brussels Top
Line].[Closed By] = CurrentUser()

but nothing happens.

I tried each functions individully (now() and currentuser()) as a part of
then statement and they both work. But they don't work together.

I thought that using IF was rather straight forward: "if condition then
result1 and result2"

but I guess I'm doing something wrong. If anyone knows what it is I would
really appreciate your help.

Thanks a lot in advance.
 
Back
Top