Couple of issues here.
1. The procedure name - Passed_To_Change - suggests you have a control
named
Passed_To. You also declared a variable named Passed_To. That's
ambiguous,
so anything could happen. In fact, it looks like all the variables in the
Dim line might also be controls. Try removing the entire Dim line.
2. If there is nothing in the control, it is Null.
Len(Null) is Null.
Null is not true, so the Else block executes.
In the Else block, you used Another If, which again evaluates to Null.
Null is still not True, so this block does not run either.
This is error #6 in this article:
Common errors with Null
at:
http://allenbrowne.com/casu-12.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
Hi Allen,
Here's my code....
Private Sub Passed_To_Change()
Dim Passed_To, Date_passed, Ldate_passed, Lpassed_To
Passed_To = Forms![Support Logs]![Passed to] & " "
Date_passed = Forms![Support Logs]![Dated Passed] & " "
Ldate_passed = Len(Date_passed)
Lpassed_To = Len(Trim(Passed_To))
If (Len([Passed_To]) > 2 And Len([Date_passed]) < 2) Then
Forms![Support Logs]![Dated Passed] = Now()
Else
If Len([Passed_To]) < 2 Then
Forms![Support Logs]![Dated Passed] = ""
End If
End If
End Sub
The first time in it works fine ie displays the date in the [Date
Passed]
field, but if I blank the Passed To field value it does not clear the
[Date
Passed] field. It still holds the original entry value in the string
variable
[Passed To], so the Len function always returns a value > 2.
Is there a better way to do what I want?
I'm an Access novice so your help is very much appreciated.
Regards,
Andy
:
Note sure exactly what you are doing here, but the control that
currently
has the focus is:
Me.ActiveControl
or even:
Screen.ActiveControl
Of course, it might not have a Value that can be compared to anything,
e.g.
if it is a command button.
Is there a common variable name/s that field inputs are held in that
can
be
used from within an Event Module? I've been checking
len(trim(form!VariableName)) but it keeps returning it's overall
length
even
when I enter blanks, so it's not much good for checking against.