[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Vb for Access code not work

Posted on 2004-08-30
5
Medium Priority
?
235 Views
Last Modified: 2013-11-27
I am using the following code (which is the same as i used in another database) but it stops at set rstCLP    saying run time error 13 type mismatch

   'add DAO 3.6 object library
   
    Dim rstDB As Database
    Dim rstCLP As Recordset
    Dim rstSumm As Recordset
     
    Set rstDB = CurrentDb
   
    Set rstCLP = rstDB.OpenRecordset("SELECT * FROM CLP")
    Set rstSumm = rstDB.OpenRecordset("SELECT * from CLPSummary")

CLP and CLPSummary are valid tables (linked) in the current database.  My plan is to read from the CLP table and write to the CLPSummary table
0
Comment
Question by:jimcrint
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 5

Expert Comment

by:rsriprac
ID: 11937467
Could you try the following:

    Dim rstDB As New Database
    Dim rstCLP As  New Recordset
    Dim rstSumm As  New Recordset

   
   rstDB = CurrentDb
   
   rstCLP = rstDB.OpenRecordset("SELECT * FROM CLP")
   rstSumm = rstDB.OpenRecordset("SELECT * from CLPSummary")

-Ram
0
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 1000 total points
ID: 11937614
try this change (I assume that you are using this code in Access 2000+):

   Dim rstDB As New Database
    Dim rstCLP As  New DAO.Recordset
    Dim rstSumm As  New DAO.Recordset

   
   Set rstDB = CurrentDb
   
   Set rstCLP = rstDB.OpenRecordset("SELECT * FROM CLP")
   Set rstSumm = rstDB.OpenRecordset("SELECT * from CLPSummary")


ADO is the default Data Access Technology in Access 2000 ( and newer) and thus a Recordset is declared as ADO.Recordset by default.  An ADO recordset is a DIFFERENT TYPE from a DAO Recordset, hence the Type Mismatch.

AW
0
 
LVL 1

Author Comment

by:jimcrint
ID: 11938198
The DAO was the answer but the new in the declarations were not allowed or required in this context.

I am now able to access the tables and manipulate the data to my hearts content

Thank you
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 11938288
that is correct, in fact, the use of New in a Declaration is NOT a good idea, and I should have noticed that.  I simply Cut and Pasted the previous suggestrion, and changed the declaration to DAO. for the recordset object.  Am I baaaaad or what - wasn't looking carefully.

Glad you have resolved the issue.  Glad to be of some small measurwe of assistance.

You can accomplish the same end result, by moving the DAO reference ABOVE the ADO reference, or by deleting the ADO reference altogether (Tools/References).

AW
0
 
LVL 19

Expert Comment

by:Arno Koster
ID: 11939748
maybe you could use a

SELECT * INTO CLPSummary FROM CLP WHERE ....


clause ?
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question