Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    May 2001
    Location
    Maryland, USA
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Previous Monday (2003)

    I am setting up some fields on a form to calculate an expiration date. The first step in the process is to return the Monday of the week of the production date. I have this function:

    Option Compare Database

    Function GetLastMonday(ByVal dtIn)
    Dim i, dtTestDate
    For i = 0 To 7
    dtTestDate = DateAdd("d", -i, dtIn)
    If Weekday(dtTestDate) = 2 Then
    GetLastMonday = dtTestDate
    Exit Function
    End If
    Next
    End Function

    I have two text boxes: “Production” to enter the production date and the other “ZeroDate” with this expression: =GetLastMonday([Production]). But when I type the expression in and hit enter I get the “The object doesn’t contain the Automation object ‘GetLastMonday.’ message.

    I’m not sure what I’m doing wrong. Any help would be appreciated.

    Thanks,
    Eric

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,328
    Thanks
    1
    Thanked 13 Times in 13 Posts

    Re: Previous Monday (2003)

    Where did you declare the function? In that form or a module? If a module, try putting PUBLIC before it.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Re: Previous Monday (2003)

    Where did you create the function?

  4. #4
    2 Star Lounger
    Join Date
    May 2001
    Location
    Maryland, USA
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Previous Monday (2003)

    It's in a module. I put PUBLIC before it. Still doesn't want to do anything. The ZeroDate field just sits there with #Name? in it.

    Option Compare Database

    Public Function GetLastMonday(ByVal dtIn)
    Dim i, dtTestDate
    For i = 0 To 7
    dtTestDate = DateAdd("d", -i, dtIn)
    If Weekday(dtTestDate) = 2 Then
    GetLastMonday = dtTestDate
    Exit Function
    End If
    Next
    End Function

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Re: Previous Monday (2003)

    Did you name the module GetLastMonday too? That would cause the #Name error because it confuses Access. If you did, rename the module, for example to basLastMonday.

  6. #6
    2 Star Lounger
    Join Date
    May 2001
    Location
    Maryland, USA
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Previous Monday (2003)

    Great! That did it. Works now. Thank you.

    Eric

Posting Permissions

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