Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Jan 2003
    Location
    Central Florida, USA
    Posts
    505
    Thanks
    5
    Thanked 0 Times in 0 Posts

    CurrentDb ? (97 and 2k)

    I copied the following code from a control event in a database that works:

    Option Compare Database
    Option Explicit

    Private Sub Command0_Click()
    Dim dbs As Database
    Dim rst As Recordset
    Dim month, year As Integer
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblSORM_00_02", dbOpenDynaset)

    However, when I try to run the code in a new database I get Type mismatch error on the last line. I checked the references and they appear the same in both databases. Does anyone have any idea where I should look for the remedy?

    Thanks.
    Ken

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

    Re: CurrentDb ? (97 and 2k)

    DO you have a reference set to ADO in the 2k database? If so, you need to specify the recordset in the declaration like this:

    Dim rst As DAO.Recordset

    Otherwise, Access 2k and later assume it's an ADO recordset, and objects to the syntax.
    Charlotte

  3. #3
    4 Star Lounger
    Join Date
    Jan 2003
    Location
    Central Florida, USA
    Posts
    505
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: CurrentDb ? (97 and 2k)

    Charlotte,

    Thanks for the response. In this database, there is no references set for ADO. I have tried this on both my 2k machine as well as one with Access97. I get the same message on both versions on the same line of code. ugh!

    Thanks again.
    Ken

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: CurrentDb ? (97 and 2k)

    Why don't you send a cut down version of your database so we can see what is actually happening.

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

    Re: CurrentDb ? (97 and 2k)

    You're saying that you get this in Access 97 on an Access 97 database (not one created in a later version and converted to 97)? What version is the database that works? I think Pat's suggestion is the only way to get at this problem.
    Charlotte

  6. #6
    4 Star Lounger
    Join Date
    Jan 2003
    Location
    Central Florida, USA
    Posts
    505
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: CurrentDb ? (97 and 2k)

    Charlotte,
    Your post prompted me to recall a similar problem in the past that was addressed using the "decompile" method mentioned here in the past.

    I decompiled it, recompiled and compacted, and viola'. It worked. As an added precaution, I created a blank database and imported all objects.

    Thanks Charlotte and Pat for your suggestions.

Posting Permissions

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