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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|