Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2006
    Posts
    12

    Question Unanswered: Code in 97 doesn't work in 2000

    I have several databases that use the following code to exclude holidays and weekends when trying to calculate the number of days to complete something.

    Function NumHolidays(Sdate, Edate) As Integer
    Dim rst As Recordset, SQLText
    SQLText = "Select * From Holidays Where" _
    & "[Date] Between #" & Sdate & "# AND #" & Edate & "#;"
    Set rst = CurrentDb.OpenRecordset(SQLText)
    If rst.RecordCount = 0 Then
    NumHolidays = 0
    Else
    rst.MoveLast
    rst.MoveFirst
    NumHolidays = rst.RecordCount
    End If
    End Function


    It works perfect in Access 97. In Access 2000 I get a Run-time error '13' Type mismatch. Does anyone have any ideas how I can get this to run in 2000?

    Thanks,
    Cheryl

  2. #2
    Join Date
    Apr 2006
    Posts
    12

    Code in 97 doesn't work in 2000

    I forgot to mention, the text highlighted in red is where the debug takes me.

    Thanks,
    Cheryl

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Check your references for DAO 3.x or above.
    In fact, check the reference differences between 2 instances in 97 and 00...

    Open the VBA window - Tools - References
    George
    Home | Blog

  4. #4
    Join Date
    Apr 2006
    Posts
    12

    Code in 97 doesn't work in 2000

    Thank you. Forgive me, I don't know much about this stuff. I checked the references. In 97, Microsoft DAO 3.51 Object Library was checked. I checked that in 00, but still got the same message when I ran the query. Am I doing something wrong?

    Cheri

  5. #5
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    try Dim rst As DAO.Recordset

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by rogue
    try Dim rst As DAO.Recordset
    This is the correct answer. Reason being anything after 2k will default to an ADODB.Recordset unless you specify otherwise.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  7. #7
    Join Date
    Apr 2006
    Posts
    12

    Code in 97 doesn't work in 2000

    Thank you both - it worked!!

    Cheri

Posting Permissions

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