[RESOLVED] ADODB.Recordset wont use the Find Method.
trying to find a record in a Recordset,
both with a numeric value, and with a string value.
but ADO wont let me...
VB Code:
Private Sub CboPrice_Click()
Dim ConnString As String
ConnString = "Provider= Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\ProPsmDb.mdb;" & "Persist Security Info=False"
Set CN_Price = New ADODB.Connection
CN_Price.ConnectionString = ConnString
CN_Price.Open ConnString
Set RS_Price = New ADODB.Recordset
RS_Price.Open "select * from price", CN_Price, adOpenStatic, adLockOptimistic, adCmdText
RS_Price.Find "ptext" = CboPrice.Text ' Ptext is a string value
RS_Price.Find "id" = CboPrice.ItemData(CboPrice.ListIndex) ' numeric value
txtName.Text = RS_Price!pricename
txtPrice.Text = RS_Price!price
errors are:
1. "Argument are of the wrong type" = search with string value
2. "type mismatch" = serarch with numeric value
why wont it find?? would very much appreciate any help...
tnx in advance 2 any ideas/suggestions.
Re: ADODB.Recordset wont use the Find Method.
How about
VB Code:
Dim sSQL As String
sSQL = "SELECT ptext, id FROM pricename WHERE ptext = '" & CboPrice.Text & "'"
sSQL = sSQL & "AND id = " & CboPrice.ItemData(CboPrice.ListIndex)
RS_Price.Open sSQL, CN_Price, adOpenStatic, adLockOptimistic
txtName.Text = RS_Price.Fields.Item("ptex").Value
txtPrice.Text = RS_Price.Fields.Item("id").Value
Re: ADODB.Recordset wont use the Find Method.
wow!!!
i've wrote almost exatly the same code!!!
cooooooooooool it works.
tnx so much Hack 4 a quick reply!
nice day,
Re: ADODB.Recordset wont use the Find Method.
Quote:
Originally Posted by josephine
wow!!!
i've wrote almost exatly the same code!!!
cooooooooooool it works.
tnx so much Hack 4 a quick reply!
nice day,
Good. :)
Just one final note. I see so many, many people doing a SELECT * when all they need is one or two fields. Unless you need every field in your table in a recordset, then just SELECT what you need. In fact, even when I need all of the fields, I will list them all out in my SELECT.
Re: [RESOLVED] ADODB.Recordset wont use the Find Method.
very well! duly noted and will implement.
last tnx for the help and the guidance Hack. :thumb:
regards,