Question Access DateDiff Function Trouble - Help!

mahunter

New member
Local time
Yesterday, 23:28
Joined
Nov 5, 2013
Messages
8
All,

I'm having trouble with the Access DateDiff Function. I'm using this function in an unbound text box on a form and I get a Name? error even if I enter actual dates versus other fields on the form.

Here's the syntax of the expression:

=DateDiff("d",[11/25/13],[11/15/13])

Eventually I want the expression/calculation to calculate the run days of a piece of equipment subtracting the current date from the equipment(wire) install date to calculate run days

=DateDiff("d",[Date()],[DWP Top Wire Install Date])

Note either way I do this I get the Name? error. The text box is formatted as a General Number and the DWP Top Wire Install Date is setup at a Date/Time field.


Any help would be much appreciated,

Mark
 
Try

=DateDiff("d",#11/25/13#,#11/15/13#)

the square brackets you were using would suggest there was a control named 11/25/13 and 11/15/13 , rather than these being actual dates.

=DateDiff("d",[date1],[date2]) will work if you have two controls named date1 and date2.

Cheers
D
 
Try

=DateDiff("d",#11/25/13#,#11/15/13#)

the square brackets you were using would suggest there was a control named 11/25/13 and 11/15/13 , rather than these being actual dates.

=DateDiff("d",[date1],[date2]) will work if you have two controls named date1 and date2.

Cheers

Thanks very much this did the trick!!
 
Thank you Mihail, this fixed the problem and eliminated the Name? Error. The other issue I have is that I need the actual dates just written into the expression 11/15/13 and 11/25/13 to reference from the Form they're entered into and also have the form hold/default to the previous entry unless the fabrics are changed and then these dates would be updated by the operator. The fabrics only get changed every few months so what I want to happen is this: The operator enters the dates in the form text boxes only when the fabric changes and those date values are held as defaults unless the fabric(s) is changed; then the operator enters a new date and everything begins again. What is the best way to make this happen?

Thanks,
Mark
 
This is a bit more complicated.
In my DBs I use a table:

tblDefaults
frmName - The form that hold the control where I need to define a default value
ctrlName - The control name
DefaultValue - The value

Under the DoubleClick event for the control I manage either to add a record to this table (if not already exist) either to update the value in the field DefaultValue (if the record exist)

Under the Open event for a form, for each control, I am looking for it's DefaultValue.
If I find a record I set the default value for the control.

Hope you understand the technique because is hard for my English to explain this.
 

Users who are viewing this thread

Back
Top Bottom