• CurrentDb ? (97 and 2k)

    Author
    Topic
    #398600

    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

    Viewing 1 reply thread
    Author
    Replies
    • #763467

      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.

      • #763479

        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

        • #763522

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

        • #763523

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

        • #763586

          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.

          • #763725

            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.

          • #763726

            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.

        • #763587

          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.

      • #763480

        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

    • #763468

      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.

    Viewing 1 reply thread
    Reply To: CurrentDb ? (97 and 2k)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: