sql and adodb problem

engeltje237
01-09-2005, 03:44 AM
hey,

I've got an error in the following code.



Private Sub lstBVVO_Click()

BVVO = lstBVVO.Text

connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=KBC.mdb;Persist Security Info=False"
Set con = New adoDB.Connection
con.Open (connectionstring)
sql = "SELECT distinct agentnrintern FROM (Agent INNER JOIN Agentennummer ON Agent.agentnrextern = Agentennummer.agentnrextern)" _
& "INNER JOIN Claim_definitief ON Agentennummer.agentnrextern =" _
& "Claim_definitief.agentnrextern where Claim_definitief.BVVO= '" & BVVO & "'"
Set rec = New adoDB.Recordset

rec.Open sql, con, adOpenKeyset, adLockOptimistic, adCmdText

If Not rec.EOF Then
rec.MoveFirst
While Not rec.EOF
lstagent.AddItem rec.Fields.Item(0).Value
rec.MoveNext
Wend
End If


End Sub




But when don't use the where-clause in the query everything works perfect? What is the problem?

BVVO is a variable declared on top as dim BVVO as string

Cerryl
01-09-2005, 04:36 AM
What error are you getting?

engeltje237
01-09-2005, 05:44 AM
What error are you getting?


run-time error '-2147217913 (80040e07)' gegevenstypen komen niet overeen in criteriumexpressie'

Don't know how to translate that into English, sorry!

Cerryl
01-09-2005, 05:55 AM
That is a data type mismatch error. What data type is Claim_definitief.BVVO?

engeltje237
01-09-2005, 06:15 AM
That is a data type mismatch error. What data type is Claim_definitief.BVVO?

I think that was the problem. That was a number en the other was a name (so string) :chuckle: Thanks!!!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum