Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mis Match on Record Set 1

Status
Not open for further replies.
May 5, 2002
79
US
I am using one of the Microsoft Report Examples (Phone book type headers). The code is:

Private Sub ReportFooter4_Format(Cancel As Integer, FormatCount As Integer)

Dim dbs As Database
Dim rst As Recordset

' Set flag after first pass has been completed.
gLastPage = True

' Open recordset for report.
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(&quot;qryBuddyByLastName&quot;, dbOpenDynaset)<==== FAILS WITH TYPE MISMATCH.
' Move to last record in recordset.
rst.MoveLast
' Enter last record into array.
ReDim Preserve gLast(Reports!rptHunterPhoneList.Page + 1)
gLast(Reports!rptHunterPhoneList.Page) = rst!LastName

End Sub

What type mismatch is occuring? Is there a special object library that must be in references?

Help would be greatly appreciated.
 
You don't say what version you are using, but if it's 2k the default object library is ADO and your code is DAO. If this is the problem you need to reference the Microsoft DAO3.6 object library (tools, references from the code window) and either move it up above the ADO reference in the dialogue box, or be more specific with your code e.g.
Dim rst As DAO.Recordset

HTH

Nigel
 
Thanks. The explicit referencing help as I already had the DAO3.6 reference library checked.
 

Just a quick thought - but it would be more beneficial if you Set your recordset with &quot;dbOpenSnapShot&quot; so that it doesn't use as much resources. It looks like you're just trying to populate with the last record information. &quot;dbOpenDynaset&quot; is used if you're going to modify the record in any way.

Next, when working with recordsets and I'm either doing a .RecordCount or anything with the data, I populate the recordset first. To do this, the line after the &quot;rst.MoveLast&quot;, would be &quot;rst.MoveFirst&quot; then you can use the .FindFirst or whatever. This could be the issue you're running into.

The next possibility is what table or query you're referring to. By the looks of your coding, it looks as if you're referring to a Query - you should make sure that this query is a &quot;Select&quot; query. If the query has multiple tables linked within, the Recordset will not be updateable which is where you would get the error if you're telling it to &quot;dbOpenDynaset&quot; (hence the switch to &quot;dbOpenSnapshot&quot;)

Roy
aka BanditWk
roy@cccamerica.org
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top