【问题标题】:Is there a way to use a variable/combo box to select a year in a date without using date pickerIs there a way to use a variable/combo box to select a year in a date without using date picker
【发布时间】:2022-12-01 15:19:18
【问题描述】:

I am working on a calculator to track my (and my coworkers may use it) overtime at work. We have a bunch written in excel, but I am trying to do one in access. There is probably a simple solution, but having searched for a couple days for using a variable in a date has only given me how to use the date as a variable. So our pay periods are defined 1/1/yyyy to 1/15/yyyy etc. Hour pay is calculated on the number of days we have in a pay period which varies every year by days off. I have it calculating the proper number of days using VBA, but I am having difficulty getting it to use the combo box year which defaults to current year.

I have tried setting the control source to = 01/01/[cmbYearselect]

using variables, creating a string in vba and format date

Any help would be appreciated as I am going to have to use the variable in both the control sources and vba code.

Thank you

01/01/[cmbYearSelect] results in 12/30/1899 on my form

everything else has resulted in a type mismatch for the variables etc.

【问题讨论】:

    标签: vba ms-access


    【解决方案1】:

    Use CDate with no year:

    =CDate(#01/01#)
    

    or:

    =CDate("01/01")
    

    to have primo of the current year.

    【讨论】:

      猜你喜欢
      • 2022-12-02
      • 2022-12-02
      • 1970-01-01
      • 2022-12-01
      • 2022-12-26
      • 2022-12-28
      • 2022-12-27
      • 2022-12-27
      • 2022-12-02
      相关资源
      最近更新 更多