Full Version: Calculated Date field on a form
UtterAccess Forums > Microsoft® Access > Access Forms
I'm attempting to create a calculated field in my form using the following calculation inside expression builder:
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.
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.
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))
AWESOME, I'm not completely sure that it's working as designed yet but it's yielding numeric values at least.
What exactly is a DLOOKUP? Is there any good reference on the web about it?
Try Access Help or Avvess VB Help which you should already have on your PC ...
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.