Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2002
    Location
    Island of Dots
    Posts
    316

    Unanswered: Validating a Week Ending

    I am creating a form to search/create records. The main field is a Week-Ending. I want to validate this so that it will only accept Sunday dates. I'm not really sure where to start. Maybe I could make a formula which would populate a table containing a list of all possible Sunday dates for the next 10 years, and perform a DLookup and validate that way? If anyone has any suggestions, please let me know!

    Thanks.

  2. #2
    Join Date
    Nov 2001
    Posts
    336
    VBA already has a function Weekday(). It may be what you need.

    Igor

  3. #3
    Join Date
    Feb 2002
    Location
    San Antonio, TX
    Posts
    69

    Re: Validating a Week Ending

    I have several programs that require me to create a list box or combo box with week ending dates starting from a specified date. I usually put the following code in the load event of the form containing the list box:

    Private Sub Form_Load()
    Dim dtPPE As Date
    Dim strPPE As String

    dtPPE = Date - WeekDay(Date) + 1
    Me![CTL_PPE].Value = dtPPE
    strPPE = dtPPE & ";"
    Do While dtPPE > "1/1/02"
    dtPPE = dtPPE - 7
    strPPE = strPPE & dtPPE & ";"
    Loop

    Me![CTL_PPE].RowSource = strPPE
    End Sub

    where CTL_PPE = the list box. This may not be the best way to accomplish this task but it works for my applications.

    HTH
    "Doing stuff is overrated. Take Hitler for example. He did lots but don't we all wish he'd have just stayed home and gotten stoned?"

  4. #4
    Join Date
    Jul 2002
    Location
    Island of Dots
    Posts
    316
    Thanks for the info guys. Weekday() was just what I was looking for.

Posting Permissions

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