A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

get month 1/2007 after 12/2006



 
 
Thread Tools Display Modes
  #1  
Old December 11th, 2006, 11:55 AM posted to microsoft.public.access.forms
anil
external usenet poster
 
Posts: 56
Default get month 1/2007 after 12/2006

hi all
I am using this functioin in my module

' looks the maximum/last date when the sampling schedule for
wastewater was generated
rst.Seek "=", DMax("Adate", "tbllog", "[sampletakenforID] = 2 ")
MsgBox "Latest Date found = '" & DMax("Adate", "tbllog",
"[sampletakenforID] = 2 ") & "' ." & vbCrLf & " " & vbCrLf & "You
already have generated the Sites for this Month."

If Month(Forms!frmww!SelectMonth) = Month(DMax("Adate", "tbllog",
"[sampletakenforID] = 2 ")) + 1 Then
' Confirms if user wants to generate the sampling schedule for next
month

now when i selects for january ,It gives message that select 13 in
month ( in form).
Can you please help so that i caould get month 1/2007 or january after
december.

thanks
anil

  #2  
Old December 11th, 2006, 12:30 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default get month 1/2007 after 12/2006

The Month function is simply returning a number between 1 and 12, and Access
has no idea that when it adds 1 to that number, it should "wrap around" to
1, rather than 13.

Try:

If Month(Forms!frmww!SelectMonth) = Month(DateAdd("m", 1, DMax("Adate",
"tbllog",
"[sampletakenforID] = 2 "))) Then

or

If Month(Forms!frmww!SelectMonth) = (Month(DMax("Adate", "tbllog",
"[sampletakenforID] = 2 ")) + 1 Mod 12) Then


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"anil" wrote in message
ups.com...
hi all
I am using this functioin in my module

' looks the maximum/last date when the sampling schedule for
wastewater was generated
rst.Seek "=", DMax("Adate", "tbllog", "[sampletakenforID] = 2 ")
MsgBox "Latest Date found = '" & DMax("Adate", "tbllog",
"[sampletakenforID] = 2 ") & "' ." & vbCrLf & " " & vbCrLf & "You
already have generated the Sites for this Month."

If Month(Forms!frmww!SelectMonth) = Month(DMax("Adate", "tbllog",
"[sampletakenforID] = 2 ")) + 1 Then
' Confirms if user wants to generate the sampling schedule for next
month

now when i selects for january ,It gives message that select 13 in
month ( in form).
Can you please help so that i caould get month 1/2007 or january after
december.

thanks
anil



  #3  
Old December 11th, 2006, 09:59 PM posted to microsoft.public.access.forms
anil
external usenet poster
 
Posts: 56
Default get month 1/2007 after 12/2006

thanks Douglas
First Method worked.
I tried the same method yesterday but was giving error.
must be wrong time of day or any small error.
Thanks for your time and help
anil
Douglas J. Steele wrote:
The Month function is simply returning a number between 1 and 12, and Access
has no idea that when it adds 1 to that number, it should "wrap around" to
1, rather than 13.

Try:

If Month(Forms!frmww!SelectMonth) = Month(DateAdd("m", 1, DMax("Adate",
"tbllog",
"[sampletakenforID] = 2 "))) Then

or

If Month(Forms!frmww!SelectMonth) = (Month(DMax("Adate", "tbllog",
"[sampletakenforID] = 2 ")) + 1 Mod 12) Then


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"anil" wrote in message
ups.com...
hi all
I am using this functioin in my module

' looks the maximum/last date when the sampling schedule for
wastewater was generated
rst.Seek "=", DMax("Adate", "tbllog", "[sampletakenforID] = 2 ")
MsgBox "Latest Date found = '" & DMax("Adate", "tbllog",
"[sampletakenforID] = 2 ") & "' ." & vbCrLf & " " & vbCrLf & "You
already have generated the Sites for this Month."

If Month(Forms!frmww!SelectMonth) = Month(DMax("Adate", "tbllog",
"[sampletakenforID] = 2 ")) + 1 Then
' Confirms if user wants to generate the sampling schedule for next
month

now when i selects for january ,It gives message that select 13 in
month ( in form).
Can you please help so that i caould get month 1/2007 or january after
december.

thanks
anil


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:19 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.