Date()+dLookup

R

Ripper

Is there a way to have an unbound field in a subform do a calculation that
will add the value from another field [AssignDate] to the dLookUp value
DLookUp("[DHallExpiration]",[tblExtraInfo])

I tried it the easy way and get a #Name? error.
 
J

Jeff Boyce

The #Name error happens when Access can't "read" what you've written. Take
a look at Access HELP on the exact syntax required for DLookup()...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
F

fredg

Is there a way to have an unbound field in a subform do a calculation that
will add the value from another field [AssignDate] to the dLookUp value
DLookUp("[DHallExpiration]",[tblExtraInfo])

I tried it the easy way and get a #Name? error.

Each argument in the DLookUp must be a string.
As written, the table argument is not a string.
And you appear to have neglected the = sign.

=DLookUp("[DHallExpiration]","[tblExtraInfo]")

Look up the DLookUp function in VBA help,
as well as Where Clause + Restrict data to a subset of records
 
R

Ripper

If I place the dLookup in the unbound box by itself I get the number 7. I
try to add it to a field stored as a date and get #Error. I am assuming then
that the error is due to the lookup being text and the date being a date. Is
there a way to retrieve a number from the dLookup and add it to a date?

=DLookUp("[DHallExpiration]","[tblExtraInfo]")+[DateAssigned] is the formula
I tried
--
Thanks As Always
Rip


fredg said:
Is there a way to have an unbound field in a subform do a calculation that
will add the value from another field [AssignDate] to the dLookUp value
DLookUp("[DHallExpiration]",[tblExtraInfo])

I tried it the easy way and get a #Name? error.

Each argument in the DLookUp must be a string.
As written, the table argument is not a string.
And you appear to have neglected the = sign.

=DLookUp("[DHallExpiration]","[tblExtraInfo]")

Look up the DLookUp function in VBA help,
as well as Where Clause + Restrict data to a subset of records
 
F

fredg

If I place the dLookup in the unbound box by itself I get the number 7. I
try to add it to a field stored as a date and get #Error. I am assuming then
that the error is due to the lookup being text and the date being a date. Is
there a way to retrieve a number from the dLookup and add it to a date?

=DLookUp("[DHallExpiration]","[tblExtraInfo]")+[DateAssigned] is the formula
I tried

You're not giving the necessary information.
What is the Datatype of [DHallExpiration]?
Is the 7 a Number value or a Text value?
Are you sure that [DateAssigned] is a Date datatype or a date value
stored as Text?

In any event, if you wish to add 7 (days) to a Date datatype Field,
then
= [DateAssigned] + 7 should work .... but only if the 7 is a Number
value not Text "7".

Therefore, if [DHallExpiration] is a Number datatype, and
[DateAssigned] is a Date datatype, then
=DLookUp("[DHallExpiration]","[tblExtraInfo]")+[DateAssigned]
should work.

Make sure the name of this control is NOT the same as the name of any
field used in it's control source expression.
 
R

Ripper

Dang it! Sorry to waste your time Fred. I looked back at the table and saw
it was text. I changed it to date and WHAMO! it worked.

Thanks for making me check my sources!
--
Sorry to was your time!
Rip


fredg said:
If I place the dLookup in the unbound box by itself I get the number 7. I
try to add it to a field stored as a date and get #Error. I am assuming then
that the error is due to the lookup being text and the date being a date. Is
there a way to retrieve a number from the dLookup and add it to a date?

=DLookUp("[DHallExpiration]","[tblExtraInfo]")+[DateAssigned] is the formula
I tried

You're not giving the necessary information.
What is the Datatype of [DHallExpiration]?
Is the 7 a Number value or a Text value?
Are you sure that [DateAssigned] is a Date datatype or a date value
stored as Text?

In any event, if you wish to add 7 (days) to a Date datatype Field,
then
= [DateAssigned] + 7 should work .... but only if the 7 is a Number
value not Text "7".

Therefore, if [DHallExpiration] is a Number datatype, and
[DateAssigned] is a Date datatype, then
=DLookUp("[DHallExpiration]","[tblExtraInfo]")+[DateAssigned]
should work.

Make sure the name of this control is NOT the same as the name of any
field used in it's control source expression.
 
Top