Between the two answers I was able to get it to work. Thank you very much.
I was not able to use the isnull function and the eval function worked the
way it was supposed to. In other words, when I used the isnull function, it
didn't return the answer True for combo49 being Null, even though the value
was removed (and therefore didn't execute the code), whereas it did return
the answer True when I used the eval function.
I am curious how the isnull funtion is supposed to to work and what the
nuances are because I have used the eval function a lot in my code. It works
well, but I would prefer to use the isnull if it is better and it does what
it is supposed to do. I got that code when I moved from Access 2 macros to
using VBA code in Access 97. Access put that into the code when it converted
the Access 2 macros. I just continued to use it because it worked.
I suppose I should have told you that I was starting in the combo49 control.
What I needed it to do was execute the code you helped me with in the event
the value in the combo49 is removed. In other words, if the value is
removed, it is supposed to delete what is in ProjEndDate and go back to
combo49 (the key to getting it to work was setting the control Projenddate
value to Null, which I didn't know how to do - I still don't really
understand why it would not allow it to go back to combo49, but that is a
mute point for now).
If the user just replaces the value in combo49 with a different value (i.e.,
updates it), it is supposed to go on to execute other code, which is why I
have it exit the sub. The rest of the code is working fine.
Klatuu said:
What you are trying to do should be in the Before update event. Also, you
don't need the Eval function. Unless there is code following the Exit Sub,
you don't need it. Is Null is for SQL, in VBA you use the IsNull Function.
Try this in the Before Update event:
If IsNull("[Forms]![RequestForm]![combo49]) Or
IsNull([Forms]![RequestForm]![periodend]) Then
With Me
.Label67.Visible = False
.ProjEndDate.Visible = True
.Undo
End With
Cancel = True
End If
--
Dave Hargis, Microsoft Access MVP
:
I'm doing a relatively simple after update event procedure that is not
letting me go back to the control from which I start. Can you tell me what I
need to do?
If (Eval("[Forms]![RequestForm]![combo49] Is Null or
[Forms]![RequestForm]![periodend] Is Null")) Then
Me!Label67.Visible = False
Me!ProjEndDate.Visible = True
DoCmd.GoToControl "ProjEndDate"
DoCmd.RunCommand acCmdDelete
DoCmd.GoToControl "combo49"
End If
Exit Sub