Results 1 to 12 of 12

Thread: about Database record please help me

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2002
    Posts
    40

    about Database record please help me

    Example:
    Private Sub nextrecord_Click()
    Dim rs As Recordset
    strsql = "select username from regedit "
    Set rs = db.OpenRecordset(strsql)
    rs.MovePrevious
    txtFields.Text = rs.Fields(0).Value
    End Sub

    If I click nextrecord command I can get the second record. If I click it again.I can't get the third record.So how to write these code ?
    Thank u!

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Edit: wrong answer

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: about Database record please help me

    Originally posted by flyflydream2002
    Example:
    Private Sub nextrecord_Click()
    Dim rs As Recordset
    strsql = "select username from regedit "
    Set rs = db.OpenRecordset(strsql)
    rs.MovePrevious
    txtFields.Text = rs.Fields(0).Value
    End Sub

    If I click nextrecord command I can get the second record. If I click it again.I can't get the third record.So how to write these code ?
    Thank u!
    OK, the following should be OUTSIDE this particular sub

    Code:
    'probably in form load event
            Dim rs As Recordset
            strsql = "select username from regedit "
            Set rs = db.OpenRecordset(strsql)
    
    Private Sub nextrecord_Click()
    rs.movenext
    if rs.eof then
    rs.movelast
    end if
    txtFields.Text = rs.Fields(0).Value
    End Sub
    HTH

  4. #4
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    Create the variable in the General declaration section of the form.

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2002
    Posts
    40
    Private Sub nextrecord_Click()

    rs.MoveNext "there is a mistake,message:"no with variable"
    If Not rs.EOF Then
    rs.MoveNext
    txtFields.Text = rs.Fields(0).Value
    End If


    End Sub

  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2002
    Posts
    40
    Create the variable in the General declaration section of the form.


    __________________
    Amitabh Kant //////
    I had done it.
    example:
    Option Explicit
    Const DBName As String = "\db197.mdb"
    Dim strPath As String
    Dim db As Database
    Dim strsql As String
    Dim blnview As Boolean
    Dim rs As Recordset


  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    i forgot...

    VB Code:
    1. Option Explicit
    2. Const DBName As String = "\db197.mdb"
    3. Dim strPath As String
    4. Dim db As Database
    5. Dim strsql As String
    6. Dim blnview As Boolean
    7. Dim rs As Recordset
    8.  
    9. Private Sub Form_load()
    10. set rs = new recordset
    11.         strsql = "select username from regedit "
    12.         Set rs = db.OpenRecordset(strsql)
    13.  
    14. end sub
    15.  
    16.  
    17. Private Sub nextrecord_Click()
    18. rs.movenext
    19. if rs.eof then
    20. rs.movelast
    21. end if
    22. txtFields.Text = rs.Fields(0).Value
    23. End Sub

  8. #8

    Thread Starter
    Member
    Join Date
    Jun 2002
    Posts
    40
    set rs = new recordset/////////message:"invalidation use new keys.

  9. #9
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Unhappy This is humiliating...

    Set db = CurrentDb()

  10. #10

    Thread Starter
    Member
    Join Date
    Jun 2002
    Posts
    40
    message:"no function or sub was defined!"

  11. #11
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

  12. #12

    Thread Starter
    Member
    Join Date
    Jun 2002
    Posts
    40
    no matter.
    thank u very much.
    I had seen that an article,But I don't know how to do it yet.
    So can you tell me about it detailly?
    :-)

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