Full Version: Calculated Date field on a form
UtterAccess Forums > Microsoft® Access > Access Forms
Newbie74
I'm attempting to create a calculated field in my form using the following calculation inside expression builder:
IIf(IsNull([TABLE]![Date_Closed]),DateDiff([h],Now(),[TABLE]![Date_Opened]),Dat
eDiff([h],[TABLE]![Date_Closed],[TABLE]![Date_Opened]))
This seems to be a very straight-forward thing and I'm getting the "#NAME?" error....
Essentially the field should be a calculation of two fields assuming both fields have data, if not the "date_closed" field should be substituted for today's date.....
This is under the control source attribute....
Is there a way to run expression builder code and see what you get?
Any and all insight would be helpful.
fkegley
Are you trying to fetch directly from a table named TABLE?
If so, then that isn't how you do it. You would use DLookup to fetch the needed value.
theDBguy
Welcome to UA!
don't think you can directly refer to table fields that way. Are the fields you're trying to evaluate in the record source of the form? If so, you can try:
=IIf(IsNull(DateClosed), DateDiff("h", Date_Opened, Now()), DateDiff("h", Date_Opened, Date_Closed))
HTH
Newbie74
AWESOME, I'm not completely sure that it's working as designed yet but it's yielding numeric values at least.
IIf(IsNull([Date_Closed]),DateDiff("d",[Date_Opened],Now()),DateDiff("h",[Date_Opened],[Date_Closed]))
Newbie74
What exactly is a DLOOKUP? Is there any good reference on the web about it?
vtd
Try Access Help or Avvess VB Help which you should already have on your PC ...
theDBguy
Looks like you won't need DLookup() if your fields are in the same record source as the form. Why couldn't you verify if the numbers being returned are the correct ones?
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.