An “IIf†problem

G

Gnerks

Yesterday, Mr. Steele gave me the following Control Source code for my
property setting on my Status textbox which works for the mixed text-date
table fields. =IIf([txtSTART1]<>"N/A" And
[txtCalculation1]<>"N/A",IIf(CDate([txtSTART1])>CDate([txtCalculation1]),"Delayed","In-Progress"),"Complete")

I changed the last item, Null, to “Complete†based on the user selecting an
option button that set the Start, End, and Status textboxes to N/A. It
works great!

Now, I need to either add another IIf statement (totally clueless where) or
set the Control Source for the Status textbox to be what was provided by Mr.
Steele for a LostFocus or After Update Event against the Start textbox, AND a
separate IIf statement or Control Source for the Status textbox for either a
LostFocus or AfterUpdate Event of the End textbox.

The piece of IIf that I need simply changes the Status textbox to “COMPLETEâ€
if there is anything in the End textbox (therefore after the End looses focus
or updates). I have tried multiple permentations of the code provided by Mr.
Steele and I have tried setting the controls in the Start and End LostFocus
and AfterUpdate events – nothing has worked. The code doesn’t read
correctly, and is provided below:


Private Sub txtEND2_LostFocus()
If txtEND2.Value = "N/A" Then
txtTOTAL2.Value = "N/A"
End If
If txtEND2.Value <> "N/A" Then
txtTOTAL2.Value = DateDiff("d", Me.[PHASE 2 START], Me.[PHASE 2 END])
txtSTATUS2.ControlSource = IIf([txtEND2] <> "N/A", "Complete", " ")
{{crashes here}}
End If
End Sub

Private Sub txtSTART2_LostFocus()

If txtSTART2.Value <> "N/A" Then
txtSTATUS2.ControlSource = IIf([txtSTART2] <> "N/A" And
[txtCalculation2] <> "N/A", IIf(CDate([txtSTART2]) >
CDate([txtCalculation2]), "Delayed", "In-Progress"), "Complete") {{crashes
here}}
End If
End Sub

Thank you for your help!
 

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