Find and bookmark function of adodc to a data control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jaz215
    New Member
    • Nov 2007
    • 55

    Find and bookmark function of adodc to a data control

    hi! in my program i'm using the find and bookmark function of the adodc control. as the people want me to use a normal data control, when i tried to run it using the same commands i've got an error. is there any other way to do this function through a data control? i'll post on what i've got but i it seems no to work. can anyone help me pls..

    Code:
    Dim counter As Integer
    counter = 0
    adoEmployee.Recordset.MoveFirst
    Do While adoEmployee.Recordset.EOF
        MsgBox (adoEmployee.Recordset.Fields(0).Value)
        If txtInputID.Text = adoEmployee.Recordset.Fields("EmployeeID").Value Then
            counter = 1
        End If
        adoEmployee.Recordset.MoveNext
    Loop
    If counter = 0 Then
        MsgBox "Employee ID does not exist", vbInformation, "Find Failure"
        txtInputID.Text = ""
        txtInputID.SetFocus
        adoEmployee.Recordset.MoveFirst
        Exit Sub
    End If
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    Why Loop through complete Record set. Use "Find" method of ADODC..

    Check this out :

    [CODE=vb]
    adoEmployee.Rec ordset.MoveFirs t
    adoEmployee.Rec ordset.Find "EmployeeID ='" & txtInputID.Text & "'"
    If adoEmployee.Rec ordset.NoMatch Then
    MsgBox "No Matching Record Found"
    Else
    MsgBox "Match Found ,..Name Is " & adoEmployee.Rec ordset("EmpName ")
    End If
    End If[/CODE]

    Regards
    Veena

    Comment

    • jaz215
      New Member
      • Nov 2007
      • 55

      #3
      Hi,

      I've tried what you said but it doesn't work. an error i got (object doesnt support property or method) its probably because i'm not using adodc, im using a normal data control (sorry if the naming got you confused) does anyone know how to find using normal data control?

      ** what i mean about normal data control is the one that's is already in the toolbox without adding components

      Comment

      • lotus18
        Contributor
        • Nov 2007
        • 865

        #4
        Hi jaz215

        [CODE=vb]Dim counter As Integer
        counter = 0
        adoEmployee.Rec ordset.MoveFirs t
        Do While adoEmployee.Rec ordset.EOF
        MsgBox (adoEmployee.Re cordset.Fields( 0).Value)
        If txtInputID.Text = adoEmployee.Rec ordset.Fields(" EmployeeID").Va lue Then
        counter = 1
        End If
        adoEmployee.Rec ordset.MoveNext
        Loop
        If counter = 0 Then
        MsgBox "Employee ID does not exist", vbInformation, "Find Failure"
        txtInputID.Text = ""
        txtInputID.SetF ocus
        adoEmployee.Rec ordset.MoveFirs t
        Exit Sub
        End If[/CODE]

        When opening your recordset, try this:

        [code=vb]
        "Select * From <TableName> Where <FieldName>=' " & Text1.Text & "'"
        [/code]

        Comment

        • jaz215
          New Member
          • Nov 2007
          • 55

          #5
          Hi lotus & queen!

          I've found out what the problem is, there is no find in datacontrol only findfirst :P (i thought the code was correct as there were no error before i run it) sorry for the trouble you guys! thanks for the help!

          Comment

          • QVeen72
            Recognized Expert Top Contributor
            • Oct 2006
            • 1445

            #6
            Originally posted by jaz215
            Hi,
            I've tried what you said but it doesn't work. an error i got (object doesnt support
            Hi,

            OK, My Coding was for ADODC. and yes, your naming got me confused.
            For normal Data Control (call it as DAO's data control)
            you can change the code (my previuos post) from
            ".Find" to ".FindFirst "
            You must have got the error in this line..
            Rest of the coding remiand same..

            Regards
            Veena

            Comment

            • jaz215
              New Member
              • Nov 2007
              • 55

              #7
              Thanks Veena & Lotus!

              Sorry about the coding convention it was my first time using the DAO :P

              Comment

              Working...