Quote:
Originally posted by boylesw
try this....
[CODE]
Dim strID as string
strID = lvwContacts.SelectedItem.Text
RS.Open "Select * from tblPcontacts where id= '" & intID & "' ORDER BY id", CN, adOpenStatic, adLockOptimistic
That will fail, because Autonumber fields are of Long Integer data type, at least in Access. When you include the single quotes in your query around the ID variable's value, the query will interpret it as a string value, because in SQL a string value is delimited in single quotes. Since the Autonumber really is a long integer, using a string value for comparison will produce the Data Type Mismatch error.