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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DAO Type Mismatch 1

Status
Not open for further replies.

AppStaff

Programmer
Sep 21, 2002
146
US
This code errors at the Set rstTL = db.OpenRecordset(strQ2, dbOpenDynaset, dbReadOnly)

I can't figure out why. Is there a special syntax for calling a query in a recordset? The help files show that its possible though do not show specifically how to do this by calling a variable. Perhaps quotations are required or some type of string conversion, though I tried some of this and couldnt find a working combination. I've tried various options replacing the dbopendynaset, including nothing and still get the same result.

The error I get is type mismatch though when I check the values they look correct to me. I've tried to use the strQ3 option as well but I get the same error. Perhaps its something in the dlookup it doesn't like but the dlookup returns the value I'd expect and the query does exist (it is a distinctrows query and is returning values). Does anyone see my problem?

Dim rstTL As ADODB.Recordset
Dim strTL As String
Dim RefID As Integer
Dim db As DAO.Database
Dim strQ As String
Dim strQ2 As String
Dim strQ3 As String
Dim IDN As Integer

'Create Recordset of selection for list of Unique team Leaders

Set db = CurrentDb

For RefID = 1 To 19

' Do for each Team Lead in selection
strQ2 = DLookup("DCQuery", "tblReference", "ID=" & RefID & "") & "_N"
strQ3 = "SELECT * FROM " & strQ2 & ""


Set rstTL = db.OpenRecordset(strQ2, dbOpenDynaset, dbReadOnly)
 
Replace this:
Dim rstTL As ADODB.Recordset
By this:
Dim rstTL As DAO.Recordset

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks. (turns red) I found that after searching the web. I converted this from ado and neglected to change that declaration.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top