derived formula in a field on form.

Lifeseeker

Registered User.
Local time
Today, 14:42
Joined
Mar 18, 2011
Messages
273
Hi,

I have a calculated field on the form, but I'm having trouble using the datediff formula.

The idea is....I would like to first see if the time difference between two time fields is less than 2 days. If it is, then I want that field A to equal to "Yes", otherwise, "No".

In the expression box, I set the field A to equal to:

=if(DateDiff("d",[tbl_Record]![Regular_CT_Scan_Result_Available],[tbl_Record]![Start_Date])<=2,"Yes","No").

when I run the form, field A remains empty regardless.

Could anybody point me in the right direction?

Thank you very much
 
Try
=IIf(Abs(DateDiff("d",[Regular_CT_Scan_Result_Available],[Start_Date]))<=2,"Yes","No")
 
Try
=IIf(Abs(DateDiff("d",[Regular_CT_Scan_Result_Available],[Start_Date]))<=2,"Yes","No")


I am trying to do the following in the afterupdate event another calculated field, but the calculated field is working, but not this following code:

Private Sub Regular_CT_Time_Valid_AfterUpdate()
If DateDiff("d", Me.Regular_CT_Scan_Result_Available, Me.ED_Start_Date) <= 2 Then
Me.Regular_CT_Head_Timeliness.Value = "Yes"
Else
Me.Regular_CT_Head_Timeliness.Value = "No"
End If

Regular_ct_time_valid is itself a calculated field and it is working, but it shouldn't matter what field I use though, correct?

End Sub
 
When I saw your first post i was trying different things.
Including working with a form -- Note I altered your field names a little.

Private Sub Form_Current()
Dim x As Long
x = Abs(DateDiff("d", Me.ResultAvailable, Me.ScanDate))
If x < 2 Then
Me.Text6.Value = "Yes"
Me.Text6.BackColor = vbGreen
Else
Me.Text6.Value = "No"
Me.Text6.BackColor = vbRed
End If

End Sub


where text6 was a text box on a form.

Does this help?
 
When I saw your first post i was trying different things.
Including working with a form -- Note I altered your field names a little.




where text6 was a text box on a form.

Does this help?

I had this worked out as well just now actually. I moved the method to another method, which is related to it.

Afterupdate event of another field on the form.

If DateDiff("d", Me.ED_Start_Date, Me.Regular_CT_Scan_Result_Available) <= 2 Then
Me.Regular_CT_Head_Timeliness.Value = "Yes"
Else
Me.Regular_CT_Head_Timeliness.Value = "No"
End If
 

Users who are viewing this thread

Back
Top Bottom