是否有人创建了一个函数来检查格式化月/年文本字段中的缺失月份 [英] Has anyone created a function to check for missing months in a range formatted month/year text field

查看:89
本文介绍了是否有人创建了一个函数来检查格式化月/年文本字段中的缺失月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在格式化的月/年字段中检查缺少月份的功能。 ms access 2003


rudolfelizabeth

解决方案

您能否了解更多关于您拥有哪种类型范围的详细信息? 通常Range指的是一个excel对象,这是一个Access论坛。 我也不知道你的日期是字符串还是数字。  Microsoft Office将日期存储为数字,但您的日期
也可以是字符串。 日期编号从1900年1月1日开始,为1 每天也相等1. 所以2011年2月10日是40,585。


 


所以你的代码看起来像这样。 您必须考虑一个日期是在十二月,第二个日期是在下一年的一月。


OldDay =" 1/1/2011"    '作为字符串的日期


NewDay =" 3/1/2011"   '作为字符串的日期


OldMonth = month(DateValue(OldDay))


OldYear = year(DateValue(OldDay))


NewMonth = month(DateValue(NewDay))


NewYear = year(DateValue(NewDay))


SkipMonth = False


如果OldYear<> NewYear然后


  如果NewYear = OldYear + 1则


     如果NewMonth<> 1或OldMonth<> 12然后


         SkipMonth = True


     结束如果


  否则


      SkipMonth = True


  结束如果


结束如果


 


如果两个日期是一个月,则SkipMonth将为false aprat群组。如果两个日期相隔一个月,则SkipMonth将为真。        


 


I need function to check for missing months in a range formatted month/year field. ms access 2003


rudolfelizabeth

解决方案

Can yo ugive more details on what type of range you have?  Usually Range refers to an excel object and this is an Access forum.  I also don't know if your Date is a string or a number.  Microsoft office stores dates as a number but your date can also be a string.  A date number starts at Jan 1, 1900 as a 1.  Each day is also equal 1.  So Feb 10, 2011 is 40,585.

 

So your code would look something like this.  You have to consider when one date is in December and the second date is in january of the following year.

OldDay = "1/1/2011"    'a Date as a string

NewDay = "3/1/2011"   'a date as a string

OldMonth = month(DateValue(OldDay))

OldYear = year(DateValue(OldDay))

NewMonth = month(DateValue(NewDay))

NewYear = year(DateValue(NewDay))

SkipMonth = False

if OldYear <> NewYear then

   If NewYear = OldYear + 1 then

      If NewMonth <> 1 or OldMonth <> 12 then

         SkipMonth = True

      end if

   else

      SkipMonth = True

   end if

end if

 

SkipMonth will be false if the two dates are one month aprat.  SkipMonth will be true if the two dates are not one month apart.        

 


这篇关于是否有人创建了一个函数来检查格式化月/年文本字段中的缺失月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆