A couple questions with ADO


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: A couple questions with ADO

  1. #1
    JJ Guest

    A couple questions with ADO


    I am designing an inventory program using an ADO data control connected to
    an Access2000 DB. Most everything is running fine, except 2 things. I am
    not very familiar with SQL language, and I can't seen to get a working find
    button. I set it up to use an input box to get the search criteria, then
    i want it to search the entire table for a likeness match and return the
    match. How can I do this?
    Also, I want the form to display the name of the record I am viewing.
    And i got that to work except that when i click on the movenext, move previous,
    move first, move last button on the ADO control, it shows the name of the
    record i just left. I am trying to write this code in the aado_movecomplete
    object, but I can't figure it out. Please some one give me some advice on
    how i can remedy this. Thank you.

    Jason

  2. #2
    Sergey Kats Guest

    Re: A couple questions with ADO

    To search the recordset for matches use Find method

    Dim objRs As ADODB.Recordset
    ' Assuming your data control named Adodc1
    Set objRs = Adodc1.Recordset
    ' Search a field starting from the current position
    objRs.Find "YourFieldName LIKE '*" & YourSearchText & "*'"
    if Not (objRs.EOF or objRs.BOF) then MsgBox "Found it!"

    Find() also let you specify where to start searching, direction and how many
    records to skip.
    Note that LIKE only works on character data.

    ' The following works for me, try it
    Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, _
    ByVal pError As ADODB.Error, _
    adStatus As
    ADODB.EventStatusEnum, _
    ByVal pRecordset As
    ADODB.Recordset)
    If Not pRecordset.EOF Then Debug.Print "Moved: " &
    pRecordset.Fields(0).Value
    End Sub

    --
    Sergey Kats
    http://codebump.net

    "JJ" <iwishiwereme@hotmail.com> wrote in message
    news:3b05759a$1@news.devx.com...
    >
    > I am designing an inventory program using an ADO data control connected to
    > an Access2000 DB. Most everything is running fine, except 2 things. I am
    > not very familiar with SQL language, and I can't seen to get a working

    find
    > button. I set it up to use an input box to get the search criteria, then
    > i want it to search the entire table for a likeness match and return the
    > match. How can I do this?
    > Also, I want the form to display the name of the record I am viewing.
    > And i got that to work except that when i click on the movenext, move

    previous,
    > move first, move last button on the ADO control, it shows the name of the
    > record i just left. I am trying to write this code in the

    aado_movecomplete
    > object, but I can't figure it out. Please some one give me some advice on
    > how i can remedy this. Thank you.
    >
    > Jason




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center