Results 1 to 5 of 5

Thread: [RESOLVED] ADODB.Recordset wont use the Find Method.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    3rd rock from the sun
    Posts
    360

    Resolved [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:
    1. Private Sub CboPrice_Click()
    2. Dim ConnString As String
    3. ConnString = "Provider= Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\ProPsmDb.mdb;" & "Persist Security Info=False"
    4. Set CN_Price = New ADODB.Connection
    5. CN_Price.ConnectionString = ConnString
    6. CN_Price.Open ConnString
    7. Set RS_Price = New ADODB.Recordset
    8. RS_Price.Open "select * from price", CN_Price, adOpenStatic, adLockOptimistic, adCmdText
    9.  
    10. RS_Price.Find "ptext" = CboPrice.Text ' Ptext is a string value
    11. RS_Price.Find "id" = CboPrice.ItemData(CboPrice.ListIndex) ' numeric value
    12.  
    13. txtName.Text = RS_Price!pricename
    14. 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.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: ADODB.Recordset wont use the Find Method.

    How about
    VB Code:
    1. Dim sSQL As String
    2.  
    3. sSQL = "SELECT ptext, id FROM pricename WHERE ptext = '" & CboPrice.Text & "'"
    4. sSQL = sSQL & "AND id = " & CboPrice.ItemData(CboPrice.ListIndex)
    5.  
    6. RS_Price.Open sSQL, CN_Price, adOpenStatic, adLockOptimistic
    7.  
    8. txtName.Text = RS_Price.Fields.Item("ptex").Value
    9. txtPrice.Text = RS_Price.Fields.Item("id").Value

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    3rd rock from the sun
    Posts
    360

    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,

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    3rd rock from the sun
    Posts
    360

    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.


    regards,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width