Copy record/Refigure date + 7 days

S

Sharon

I am using Access 2003 and I have a "to do" form where I want to have a
command button named "Repeat". I want this to repeat the entire record but,
in place of the Due_By date currently in the field, I want it to add seven
days to that date. Not quite sure how to do that. Any help is appreciated.
Thanks.


Private Sub cmdbtnRepeat_Click()

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
DoCmd.GoToRecord , , acLast

Due_By = DateAdd("dd", 7, [Due_By])

End Sub
 
K

Klatuu

Instead of "dd" it should be "d"

You need to update your code. DoMenuItem has been obsolete since about AC97
(as I recall).
That code is impossible to read.
 
S

Sharon

I can only try and find these answers out for myself by looking at other
responses and other information obtained from the internet. I am not an
experienced Access user. Do you know what code I should use? And shouldn't I
use "dd" if I want the date to show as "01" instead of "1"?
--
S


Klatuu said:
Instead of "dd" it should be "d"

You need to update your code. DoMenuItem has been obsolete since about AC97
(as I recall).
That code is impossible to read.
--
Dave Hargis, Microsoft Access MVP


Sharon said:
I am using Access 2003 and I have a "to do" form where I want to have a
command button named "Repeat". I want this to repeat the entire record but,
in place of the Due_By date currently in the field, I want it to add seven
days to that date. Not quite sure how to do that. Any help is appreciated.
Thanks.


Private Sub cmdbtnRepeat_Click()

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
DoCmd.GoToRecord , , acLast

Due_By = DateAdd("dd", 7, [Due_By])

End Sub
 
D

Douglas J. Steele

dd would give you a two digit display in a Format property or function.
You're not using Format, you're using DateAdd, which has nothing to do with
how the resultant date will look.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Sharon said:
I can only try and find these answers out for myself by looking at other
responses and other information obtained from the internet. I am not an
experienced Access user. Do you know what code I should use? And
shouldn't I
use "dd" if I want the date to show as "01" instead of "1"?
--
S


Klatuu said:
Instead of "dd" it should be "d"

You need to update your code. DoMenuItem has been obsolete since about
AC97
(as I recall).
That code is impossible to read.
--
Dave Hargis, Microsoft Access MVP


Sharon said:
I am using Access 2003 and I have a "to do" form where I want to have a
command button named "Repeat". I want this to repeat the entire record
but,
in place of the Due_By date currently in the field, I want it to add
seven
days to that date. Not quite sure how to do that. Any help is
appreciated.
Thanks.


Private Sub cmdbtnRepeat_Click()

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste
Append
DoCmd.GoToRecord , , acLast

Due_By = DateAdd("dd", 7, [Due_By])

End Sub
 
K

Klatuu

If you want it to return a string that would show the day as 01, The it would
be:
Format(Date,"dd")

Due_By = Format(DateAdd("d", 7, [Due_By]), "dd")

If you want to return the entire date, it would be
Due_By = Format(DateAdd("d", 7, [Due_By]), "mm/dd/yyyy")

Due_By should be a string variable

Read the info on the Format and DateAdd functions in VBA Help. You will
find examples there.
--
Dave Hargis, Microsoft Access MVP


Sharon said:
I can only try and find these answers out for myself by looking at other
responses and other information obtained from the internet. I am not an
experienced Access user. Do you know what code I should use? And shouldn't I
use "dd" if I want the date to show as "01" instead of "1"?
--
S


Klatuu said:
Instead of "dd" it should be "d"

You need to update your code. DoMenuItem has been obsolete since about AC97
(as I recall).
That code is impossible to read.
--
Dave Hargis, Microsoft Access MVP


Sharon said:
I am using Access 2003 and I have a "to do" form where I want to have a
command button named "Repeat". I want this to repeat the entire record but,
in place of the Due_By date currently in the field, I want it to add seven
days to that date. Not quite sure how to do that. Any help is appreciated.
Thanks.


Private Sub cmdbtnRepeat_Click()

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
DoCmd.GoToRecord , , acLast

Due_By = DateAdd("dd", 7, [Due_By])

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top