need to make a formula that would add a field value to current dat

J

J Man

I have made a form in which I input different values. On of the values is
(How Many Days). Now I need to a assign a default value, or expression (not
sure which way to go about this) that will take the date value for (Date) and
add the value (How Many Days)

I figured that the formula should read =sum([Date]+[How Many Days])

But that is not giving me any results, thanx for your help in advance
 
J

J Man

Wayne thanx for your response, not sure what I'm doing wrong. I tried your
formula in both default value and event with no result.

Jerry

Wayne-I-M said:
=DateDiff("d", Date(), [How Many Days])


--
Wayne
Manchester, England.



J Man said:
I have made a form in which I input different values. On of the values is
(How Many Days). Now I need to a assign a default value, or expression (not
sure which way to go about this) that will take the date value for (Date) and
add the value (How Many Days)

I figured that the formula should read =sum([Date]+[How Many Days])

But that is not giving me any results, thanx for your help in advance
 
W

Wayne-I-M

Can you explain what you are trying to do

the formula I gave will give the number of days from today to the value of
the control called How Many Days.

Are you trying to get this or something else.


--
Wayne
Manchester, England.



J Man said:
Wayne thanx for your response, not sure what I'm doing wrong. I tried your
formula in both default value and event with no result.

Jerry

Wayne-I-M said:
=DateDiff("d", Date(), [How Many Days])


--
Wayne
Manchester, England.



J Man said:
I have made a form in which I input different values. On of the values is
(How Many Days). Now I need to a assign a default value, or expression (not
sure which way to go about this) that will take the date value for (Date) and
add the value (How Many Days)

I figured that the formula should read =sum([Date]+[How Many Days])

But that is not giving me any results, thanx for your help in advance
 
B

BruceM

If you want to know the date a certain number of days from the current date,
try DateAdd. For instance, as the control source of a text box:
=DateAdd("d",[HowManyDays],Date())
See Help for more information about DateAdd.

The default value for a bound control (one that is linked to a table field)
is the value that is applied when the record is new. Default value for an
unbound control on a form is the value applied when the form is first
opened. If you change the value, it will retain the new value as you
navigate through the records. I can't see that it has much use in an
unbound control. In any case, you aren't looking for default value.
I'm not sure what you mean when you say you tried the expression "in ...
event", but if you are trying to use an event procedure such as the form's
Current event you either need to use a function as the Current event, or you
need to add code to the Event Procedure. For instance:
Me.SomeTextBox = DateAdd("d",[HowManyDays],Date)
However, using the expression above as the control source of a text box
should do what you need.

J Man said:
Wayne thanx for your response, not sure what I'm doing wrong. I tried
your
formula in both default value and event with no result.

Jerry

Wayne-I-M said:
=DateDiff("d", Date(), [How Many Days])


--
Wayne
Manchester, England.



J Man said:
I have made a form in which I input different values. On of the values
is
(How Many Days). Now I need to a assign a default value, or expression
(not
sure which way to go about this) that will take the date value for
(Date) and
add the value (How Many Days)

I figured that the formula should read =sum([Date]+[How Many Days])

But that is not giving me any results, thanx for your help in advance
 
J

John W. Vinson

I have made a form in which I input different values. On of the values is
(How Many Days). Now I need to a assign a default value, or expression (not
sure which way to go about this) that will take the date value for (Date) and
add the value (How Many Days)

I figured that the formula should read =sum([Date]+[How Many Days])

But that is not giving me any results, thanx for your help in advance

Use DateAdd:

=DateAdd("d", [How Many Days], [Date])

Note that Date is a reserved word for the built in "today's date" function,
and that you should not use it as a field or controlname.

John W. Vinson [MVP]
 
B

BruceM

In my response I had taken the OP to mean adding days to the current date,
but upon rereading it does look as if Date is a field name, in which case my
expression will not work as intended.

John W. Vinson said:
I have made a form in which I input different values. On of the values is
(How Many Days). Now I need to a assign a default value, or expression
(not
sure which way to go about this) that will take the date value for (Date)
and
add the value (How Many Days)

I figured that the formula should read =sum([Date]+[How Many Days])

But that is not giving me any results, thanx for your help in advance

Use DateAdd:

=DateAdd("d", [How Many Days], [Date])

Note that Date is a reserved word for the built in "today's date"
function,
and that you should not use it as a field or controlname.

John W. Vinson [MVP]
 
J

J Man

Hi John,

Thanx for your post. I can change the field/control name from date to
something else, but in reality I only need it to add value[How Many Days] to
the current date. But just in case I ever need it to add to the value[Date]
I guess I will change the name. However I did try to use your formula and
still am having no luck. Just to be clear should I be using this formula in
the 'default value' or somewhere else? Thanx for your time. Usually with a
little work at it I can get these to work, but I've been trying to figure
this out for sometime and nothing is working. I'm sure its an easy fix, but
I'm just not getting it.

Once again thanx
Jerry

John W. Vinson said:
I have made a form in which I input different values. On of the values is
(How Many Days). Now I need to a assign a default value, or expression (not
sure which way to go about this) that will take the date value for (Date) and
add the value (How Many Days)

I figured that the formula should read =sum([Date]+[How Many Days])

But that is not giving me any results, thanx for your help in advance

Use DateAdd:

=DateAdd("d", [How Many Days], [Date])

Note that Date is a reserved word for the built in "today's date" function,
and that you should not use it as a field or controlname.

John W. Vinson [MVP]
 
J

J Man

Thanx Wayne

What I'm trying to do is as follows

I have a form in which I input a value for [How Many Days]
[Date] is defaulted to current date, but can also be changed if say I'm
backdating or entering info for the future. What I need is a formula that
will take the value [How Many Days] and add it to [Date] but so far nothing
is working. In excel this is so much easier then in access.

Thanx for your time,
Jerry

Wayne-I-M said:
Can you explain what you are trying to do

the formula I gave will give the number of days from today to the value of
the control called How Many Days.

Are you trying to get this or something else.


--
Wayne
Manchester, England.



J Man said:
Wayne thanx for your response, not sure what I'm doing wrong. I tried your
formula in both default value and event with no result.

Jerry

Wayne-I-M said:
=DateDiff("d", Date(), [How Many Days])


--
Wayne
Manchester, England.



:

I have made a form in which I input different values. On of the values is
(How Many Days). Now I need to a assign a default value, or expression (not
sure which way to go about this) that will take the date value for (Date) and
add the value (How Many Days)

I figured that the formula should read =sum([Date]+[How Many Days])

But that is not giving me any results, thanx for your help in advance
 
B

BruceM

My earlier posting on this topic explained that the expression goes into the
Control Source. In that same posting I explained Default Value, and why it
isn't what you want. I also mentioned that the expression could be used in
an Event Procedure. I will say that I had misunderstood that Date is a
field (or control), but if you surround Date with square brackets you should
be OK, even though it is not a recommended procedure to use the name of a
function for a field name. It can cause problems with code, among other
things. That is why John mentioned it. You can use Default Value to set
the value of the Date field to today's date, assuming that you are storing
the information.

J Man said:
Hi John,

Thanx for your post. I can change the field/control name from date to
something else, but in reality I only need it to add value[How Many Days]
to
the current date. But just in case I ever need it to add to the
value[Date]
I guess I will change the name. However I did try to use your formula and
still am having no luck. Just to be clear should I be using this formula
in
the 'default value' or somewhere else? Thanx for your time. Usually with
a
little work at it I can get these to work, but I've been trying to figure
this out for sometime and nothing is working. I'm sure its an easy fix,
but
I'm just not getting it.

Once again thanx
Jerry

John W. Vinson said:
I have made a form in which I input different values. On of the values
is
(How Many Days). Now I need to a assign a default value, or expression
(not
sure which way to go about this) that will take the date value for
(Date) and
add the value (How Many Days)

I figured that the formula should read =sum([Date]+[How Many Days])

But that is not giving me any results, thanx for your help in advance

Use DateAdd:

=DateAdd("d", [How Many Days], [Date])

Note that Date is a reserved word for the built in "today's date"
function,
and that you should not use it as a field or controlname.

John W. Vinson [MVP]
 
J

J Man

BruceM,

Thanx for all your help, it all works now.
I could have sworn I tried it the other day when you first sent it, with no
success. But it all works now, your a life saver. I was ready to rip my
hair out. lol

Thanx to everyone else for their help also.

Jerry

BruceM said:
My earlier posting on this topic explained that the expression goes into the
Control Source. In that same posting I explained Default Value, and why it
isn't what you want. I also mentioned that the expression could be used in
an Event Procedure. I will say that I had misunderstood that Date is a
field (or control), but if you surround Date with square brackets you should
be OK, even though it is not a recommended procedure to use the name of a
function for a field name. It can cause problems with code, among other
things. That is why John mentioned it. You can use Default Value to set
the value of the Date field to today's date, assuming that you are storing
the information.

J Man said:
Hi John,

Thanx for your post. I can change the field/control name from date to
something else, but in reality I only need it to add value[How Many Days]
to
the current date. But just in case I ever need it to add to the
value[Date]
I guess I will change the name. However I did try to use your formula and
still am having no luck. Just to be clear should I be using this formula
in
the 'default value' or somewhere else? Thanx for your time. Usually with
a
little work at it I can get these to work, but I've been trying to figure
this out for sometime and nothing is working. I'm sure its an easy fix,
but
I'm just not getting it.

Once again thanx
Jerry

John W. Vinson said:
On Tue, 18 Sep 2007 02:08:06 -0700, J Man <J
[email protected]>
wrote:

I have made a form in which I input different values. On of the values
is
(How Many Days). Now I need to a assign a default value, or expression
(not
sure which way to go about this) that will take the date value for
(Date) and
add the value (How Many Days)

I figured that the formula should read =sum([Date]+[How Many Days])

But that is not giving me any results, thanx for your help in advance

Use DateAdd:

=DateAdd("d", [How Many Days], [Date])

Note that Date is a reserved word for the built in "today's date"
function,
and that you should not use it as a field or controlname.

John W. Vinson [MVP]
 
Top