Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2011
    Posts
    413

    Unanswered: Date Criteria Help Needed

    I want one form to open if the dates are between 2 defined fields on another form, if not then I want it to open another form instead.
    The first form that should open if the current date falls between the 2 parameters is named frmSetPayDate
    The other form that should open if the date criteria does not fall between the 2 dates is named Set TimeCards Date

    The 2 fields on the other form which is named frmAutoPayrollReport

    are named BeginDate and EndDate

    BeginDate being the start of the date week and EndDate being the end of the date week criteria.

    Something kinda sorta like this;
    IfCDate is Between Forms!frmAutoPayrollReport!BeginDate and Forms!frmAutoPayrollReport!EndDate Then ' 2 fields on another form that is open
    DoCmd.Open form frmSetPayDate ' Form
    Else

    open Set TimeCards Date' Form

    CDate referes to the date now. If I got it right

  2. #2
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    Not sure if you can use BETWEEN like that. Try this:
    Code:
    If CDate >= Forms!frmAutoPayrollReport!BeginDate AND CDate <= Forms!frmAutoPayrollReport!EndDate Then
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    isn't cdate a reserved word in Access?
    an NO it doesn't refer to the current date.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    Good point! CDate is a function call in VBA. This the problem with only seeing fragments of other people's code.
    10% of magic is knowing something that no-one else does. The rest is misdirection.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •