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.
|