Recordset error

P

PJFry

Private Sub SetForm_Click()

Dim sqlGroup As String
Dim i As Integer

Set rs = New ADODB.Recordset
Set cn = CurrentProject.Connection

i = 1

sqlGroup = "SELECT tempJobTitles.Rank, tempJobTitles.txtJobTitle,
tempJobTitles.FirstQuart" & _
" FROM tempJobTitles WHERE (((tempJobTitles.Rank)='" & i & "'));"

rs.Open sqlGroup, cn, adOpenStatic, adLockOptimistic

I am getting the following error:
Data Type Mismatch In Critera Expression

The tempJobTitles.Rank is a long integer. I am guessing that it has to do
with the i in the SQL, but I am not sure how.

Thoughts?
Thanks in advance!
PJ
 
J

Jeff Boyce

Perhaps you could define the "i" as Long (Integer)?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

George Nicholson

If you are working with Integers, lose the single quotes. They are telling
Jet to look for a string value in a numeric field which is a classic Type
Mismatch:

"...WHERE (((tempJobTitles.Rank)=" & i & "));"

HTH,
 
P

PJFry

Of course! That was it. Thanks!

George Nicholson said:
If you are working with Integers, lose the single quotes. They are telling
Jet to look for a string value in a numeric field which is a classic Type
Mismatch:

"...WHERE (((tempJobTitles.Rank)=" & i & "));"

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top