Need Help in vb6, Please Read?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • psyvanz
    New Member
    • Sep 2009
    • 26

    #1

    Need Help in vb6, Please Read?

    is there any possibilities that you can make a vb6 code, that can search backwards from last to first?


    first, i just want to apologize for disturbing you..x)

    i mean, from an access 03 database

    i inputed in the fieldname: studentnumber

    then, i entered below, five(5) records of studentnumber(f ieldname) with same value 00001..( this was inputed in access 03 database, not in a vb6 project to lessen the time)

    so there are five(5) of same studentnumber, w/c is 00001?

    so, here is the thing, a vb6 code using (textbox1_chang e) must search backwards start from the fifth(5th) record 00001 to the first record...

    (the searched studentnumber must shown also in a textbox2)

    with a moveprevious and movenext commandbuttons. ..(to determine if it starts from last to first string)

    if you know this one, can i do a favor? to make an example and post it here.

    cause i just also want to know it...

    remember: sharing is good... for like me who wants to know the possibilities.

    hope you help me, that's if your not busy...

    thanks in advance...GOD bless...

    all answers is much more appreciated... again thanks for sharing...
  • vb5prgrmr
    Recognized Expert Contributor
    • Oct 2009
    • 305

    #2
    use an ORDER BY statement in your select query.

    Good Luck

    Comment

    • psyvanz
      New Member
      • Sep 2009
      • 26

      #3
      re: help

      i'd tried that one..

      studentnumber(f ieldname)

      example: studentnumber(f ieldname) had 10 same recorded number 00001..

      how it will goto the last record or the 10th record directly?

      coded like this:

      query (select * from tb1 order by studentnumber)

      but the problem is, it always starts at the first record? not on the 10th record

      will you help me on how to find the last record only..

      you may EDIT this code..

      thanks again for sharing..and thanks in advance for EDITING...

      Comment

      • vb5prgrmr
        Recognized Expert Contributor
        • Oct 2009
        • 305

        #4
        Okay, to move to the last record then you can use...
        Code:
        Rs.MoveLast
        Then to move from the last to the first...
        Code:
        Do While Not Rs.BOF
          'do whatever
          Rs.MovePrevious
        Loop


        Good Luck

        Comment

        • psyvanz
          New Member
          • Sep 2009
          • 26

          #5
          good day vb5prgrmr?

          here is the code im working with?

          it is a dataenvironment , im sure you knew this code?

          it is same like ADODC OR A MODULE code?

          if you dont know, please forward this to your experts friend who knew how to twick or trace the error..

          this code only search the first record... you had been search..

          Code:
          [B]Private Sub old_Change([/B]) ' this is a textbox, 
          
          'that searches only the first entered studentnumber 00001, but they're lots of 
          'inputed like 00002.. so on and so fort, but i inputed (3) three 00001. '
          'cause i want this search code must find the last record 00001, not the last "anynumber" in a database.
          ' ONLY the Search number entered in the "old.text" w/c i search "00001" must seek not the 00002 or the last record inputed in the database...
          
          'meaning... (3)00001,(1)00002,(1)00003
          
          'if i code rs.movelast only IM SURE IT GOTO THE LAST RECORD WHICH WAS 00003.. 
          'but i want to only the last record of 00001, because it is a search command.
          
          'hope you will help me to fix this code...
          
          'thanks...x)
          ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
          On Error Resume Next
          
          Dim findstr As String
          
              If Not DataEnvironment1.rsTranSub.Supports(adFind) Then
                  MsgBox " Doesn't support Recordset "
                  
              Else
                  If DataEnvironment1.rsTranSub.Supports(adBookmark) Then
                     lastrow = DataEnvironment1.rsTranSub.Bookmark
                  
                  End If
                  
                  findstr = old.Text
                  If findstr = "" Then Exit Sub
          
          
          
                  'DataEnvironment1.rsTranSub.Movelast
           
          [I]' I think here is the code i can't fixed below:[/I]
                
                  	[B]DataEnvironment1.rsTranSub.find "studentnumber LIKE '*" & findstr & "*'"[/B]                
                   '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                      If DataEnvironment1.rsTranSub.EOF Then
                         MsgBox "No records found!" & findstr
                    
                      If DataEnvironment1.rsTranSub.Supports(adBookmark) Then
                          DataEnvironment1.rsTranSub.Bookmark = lastrow
                   
                      End If
                End If
                  End If
              
          End Sub

          Comment

          Working...