Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Location
    Loudon, New Hampshire, USA
    Posts
    125
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Year() (Office/Access 2000)

    Hello Gang,
    Once again I find myself kornfused!!! I have been trying to use the Year function. I keep getting an error 13. Mismatch data types. I do not see the problem?? So I took the example in HELP, (which was of little help) and tried it. And you will never guess what happened????? I got an error 13. I cut and pasted the help example and I know I did NOT fat finger anything. I now wonder if this is a bug????
    On the subject of Dates. Does any one know how to use EDATE???? I when and got the DLL it wants, but it still says I am missing something. What who knows, it keeps that information to itself???
    About printing my tag data. Well I could not use documenter, as it dropped some of my tag data. I found bits and pieces in some of my books. And was able to get what I wanted using the forms collection and referencing some of its objects. I can pass on the code if anyone is interested.
    Later,
    Sarge

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Year() (Office/Access 2000)

    What is the context in which you are trying to use Year()?

    Have you checked references? Missing references cause misbehviour of built-in functions!

    What happens if you put this calculated field into a query:

    thisyear: Year(Date())
    Regards
    John



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

    Re: Year() (Office/Access 2000)

    EDATE is a worksheet function in the Analysis ToolPak add-in for Excel, not Access. In VBA and in Access expressions, you can use the DateAdd function. For example, to get the date 3 months after today, use
    <pre>DateAdd("m", 3, Date())
    </pre>

    DateAdd can also be used for other intervals, such as "d" for days, "ww" for weeks and "yyyy" for years. More info in the online help in the Visual Basic Editor.

  4. #4
    2 Star Lounger
    Join Date
    Jun 2002
    Location
    Loudon, New Hampshire, USA
    Posts
    125
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Year() (Office/Access 2000)

    John,
    As I said I took the example from Access Help and ran it. It got an error message 13. I could not find any way this function works. My question is does any one know how Year() works?????
    Later,
    Sarge

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Year() (Office/Access 2000)

    An error 13 is a type mismatch error, which means whatever you tried to pass to year isn't actually a date but something else, like a variable that evaluates to a string. Here are some results from the immediate window:

    <table border=1><td>Expression</td><td>Returns</td><td>year(date())</td><td>2004</td><td>year(date)</td><td>2004</td><td>year("date")</td><td>error 13</td><td>year("5/12/2004")</td><td>2004</td><td>year()</td><td>"argument not optional" error</td><td>year(Null)</td><td>Null</td></table>

    If none of these match what you're trying, copy and paste the exact expression you are using that returns an error so we can see what's actually going on.
    Charlotte

  6. #6
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Year() (Office/Access 2000)

    It would be useful if you could show exactly what you try to do with the example from Help.

    I did this in the immediate window, based on what I have in Help and it worked OK.

    ? Year(#February 12,1969#)
    1969
    Regards
    John



  7. #7
    2 Star Lounger
    Join Date
    Jun 2002
    Location
    Loudon, New Hampshire, USA
    Posts
    125
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Year() (Office/Access 2000)

    Ok what I did is took the Example from VBA Help for Year(). Year Function Example
    This example uses the Year function to obtain the year from a specified date. In the development environment, the date literal is displayed in short date format using the locale settings of your code.

    Dim MyDate, MyYear
    MyDate = #February 12, 1969# ' Assign a date.
    MyYear = Year(MyDate) ' MyYear contains 1969.

    But I got Error 13. You all seem to have this working. I have Month() and Day() working but not Year(). I asked if this worked for any one else when the Example in Help did NOT work.
    Still kornfused,
    Sarge

  8. #8
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Year() (Office/Access 2000)

    You haven't answer Hans' question about the references. Have you checked for missing references ?
    In the VBA editor select Tools / References and look for references marked MISSING.
    If so, uncheck them and try again.
    Francois

Posting Permissions

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