problem with my code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dwadish
    New Member
    • Nov 2006
    • 129

    problem with my code

    Hai guys ! i am razak want to debugging my bug.

    i want to search a recordset field continueously when matching it to a value of a

    dtpicker.value. i am also used this code for it but it is failed .

    my code is

    Code:
    do while no rs.eof()
    rs.findfirst "date=" & dtpicker.value
    if rs.nomatch=false then
    pad.text=rs.fields(2)
    else
    msgbox "invalid date"
    loop
    endif
    any one can help me?

    Thanx in advance..
  • vinci
    New Member
    • Aug 2006
    • 62

    #2
    Originally posted by dwadish
    Hai guys ! i am razak want to debugging my bug.

    i want to search a recordset field continueously when matching it to a value of a

    dtpicker.value. i am also used this code for it but it is failed .

    my code is

    Code:
    do while no rs.eof()
    rs.findfirst "date=" & dtpicker.value
    if rs.nomatch=false then
    pad.text=rs.fields(2)
    else
    msgbox "invalid date"
    loop
    endif
    any one can help me?

    Thanx in advance..

    i think you should switch places the "loop" and "end if"

    Code:
    do while no rs.eof()
    rs.findfirst "date=" & dtpicker.value
    if rs.nomatch=false then
    pad.text=rs.fields(2)
    else
    msgbox "invalid date"
    [B]end if    -------
    loop      ------[/B]
    just a guess....

    Comment

    • rockford333
      New Member
      • Sep 2006
      • 15

      #3
      Originally posted by dwadish
      Hai guys ! i am razak want to debugging my bug.

      i want to search a recordset field continueously when matching it to a value of a

      dtpicker.value. i am also used this code for it but it is failed .

      my code is

      Code:
      do while no rs.eof()
      rs.findfirst "date=" & dtpicker.value
      if rs.nomatch=false then
      pad.text=rs.fields(2)
      else
      msgbox "invalid date"
      loop
      endif
      any one can help me?

      Thanx in advance..

      hi,
      This the way u have to write the code for this.
      first open the connection and recordset then,

      Code:
      rs.movefirst
      while rs.eof<>true
      here u use the column no of database to search for example if its first column

      Code:
      then rs(0)
      if rs(0)<>dtpicker then
      pad.text=rs.fields(2)
      rs.close
      exit sub
      else
      rs.movenext
      end if
      wend 
      rs.close
      msgbox "invalid date"
      let me know u it will help u r not.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by rockford333
        hi,
        This the way u have to write the code for this.
        first open the connection and recordset then,
        rs.movefirst
        Code:
        while rs.eof<>true
          ' here u use the column no of database to search for example if its first column then rs(0)
          if rs(0)<>dtpicker then
            pad.text=rs.fields(2)
            rs.close
            exit sub
          else
            rs.movenext
          end if
        wend 
        rs.close
        msgbox "invalid date"
        let me know u it will help u r not.
        I'd just like to suggest to everyone in this thread that when posting code fragments, you put the [c o d e] and [/ c o d e ] tags around them (without the extra spaces I added here. As shown in the quote above, it makes your code easier to read and allows you to do neat stuff like indenting which are lost from normal text.

        Comment

        • dwadish
          New Member
          • Nov 2006
          • 129

          #5
          Originally posted by Killer42
          I'd just like to suggest to everyone in this thread that when posting code fragments, you put the [c o d e] and [/ c o d e ] tags around them (without the extra spaces I added here. As shown in the quote above, it makes your code easier to read and allows you to do neat stuff like indenting which are lost from normal text.
          thanx for you kind help. it helped me to proceed .

          happy new year

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by dwadish
            thanx for you kind help. it helped me to proceed .
            Glad it worked out, but I doubt it was my advice that helped. :)

            Comment

            Working...