Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 24th, 2006, 03:10 PM
Authorized User
 
Join Date: Jun 2006
Posts: 73
Thanks: 1
Thanked 1 Time in 1 Post
Default V.B.6 recognition of 'Dim' ed, recordsets

I have had a similar problem before, but cleaared it by checking 'installed components' and 'libraries'. However, this one seems to defy explanation ! I can run my application on the desktop with no problems, however, I have copied it to the laptop with exactly the same configuration of reference libraries in V.B.6, and components. It throws up a 'Type Mismatch' error, when it comes to set my declared recordsets i.e. as snapshots, the code is as follows :

Dim MyDb As Database
Dim s1 As Recordset
Dim s2 As Recordset
----------------------------
Later in program ....

Set MyDb = OpenDatabase("C:\My Documents\BeautyMatters.mdb")
   Set s1 = MyDb.OpenRecordset("SELECT Therapist_ID, [First Name], Surname FROM Therapists WHERE Therapist_ID=" & adoAppts.Recordset!Therapist_ID & ";", dbOpenSnapshot)
   lblShowBooking.Caption = "Booked Appointments for " & s1![First Name] & " " & s1!surname & " on " & Format(adoAppts.Recordset.Fields("Appt_Date"), "dddd, d mmmm yyyy")
   s1.Close
   Set s1 = MyDb.OpenRecordset("SELECT Therapist_ID, Appt_Date, Treatment_ID, Time_Number FROM Appointments WHERE Therapist_ID=" & adoAppts.Recordset!Therapist_ID & " And Appt_Date=#" & adoAppts.Recordset!Appt_Date & "# ORDER BY Time_Number;", dbOpenSnapshot)
   Set s2 = MyDb.OpenRecordset("SELECT Treatment_ID, Duration FROM Treatments;", dbOpenSnapshot)

You can ignore the Recordsource and S.Q.L. that's perfectly fine....

but when it gets to the 'Set' statement for s1 and s2, it throws up a 'Type Mismatch' error. Any ideas would be very gratefully received. Thanks, Liam.




 
Old December 25th, 2006, 02:43 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It could be version incompatibility.
You state that you have "copied" the same configuration of reference libraries. I am unclear regarding this. It is possible that you have not registered the dll's that your app is using, and that you merely copied them?

Are you using a development environment on the laptop? It seems that you are, as opposed to just trying to run the compiled application on the laptop. I just want to be clear on what exactly you are trying to do.

Is it possible that you are also referencing ADODB in your project (as well as DAO, which it appears you are using)? This will cause an ambiguity since both object models have a recordset component. This is a situation where it could work on one box but not on the other. If this is the case, you can fix it by simply using the complete qualifier:

Dim s1 As DAO.Recordset

Woody Z
http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Speech Recognition Mantis VB How-To 2 June 2nd, 2011 05:10 AM
Face Recognition using VC++ akshat_malviya Visual C++ 2 December 21st, 2009 02:50 PM
I need help with pattern recognition jazokita Pro Java 2 February 8th, 2009 05:34 PM
speech recognition C# soso_jaw C# 0 July 13th, 2006 08:21 AM
text recognition vb certified VB How-To 0 July 1st, 2005 01:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.