Results 1 to 7 of 7

Thread: help help

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    425

    Question help help

    Private Sub Command1_Click()
    getRecordSet
    connRs.Source = "Select * From Users"
    connRs.Open
    If connRs.EOF = True Then
    connRs.MoveFirst
    Else
    connRs.MoveNext
    Text1.Text = connRs!UserID
    Text2.Text = connRs!password
    Text3.Text = connRs!userRole
    End If
    End Sub

    This is a MoveNext command button but whenever i click it will only move to the second row of the database and will not proceed on.

    getRecordSet is a sub in my module that opens a connection and set the recordset

    i closes the recordset after loading the data from db into a listbox

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Probably because you keep reopening the recordset, which takes it back to the start.

  3. #3
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Post

    IMHO,
    If the recordset was being reopened, it would have generated an error. I do not think that is the case over here.


    Could you just post the getRecordset Sub?

    Cheers!
    Abhijit
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    425
    eh...

    i have a listbox and 3 textboxes and 1 MoveNxt command button.

    1) i open connection and recordset when i load the form to load the details into the listbox then close it. (In sub form_load)

    2) i closed the recordset in #1 because i want to change the recordset.source with some conditions and display what i clicked on to the textboxes.(In sub list1_click())

    3) i reopen the recordset so i can change the record.source get a "SELECT * FROM xxx" and moveNext the record. (In the cmd button).

    anyways i can achieve these?? without closing and reopening of record?

    thanks

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    425
    Public Sub getRecordSet()
    Call connect 'connection string setup
    Set connRs = New ADODB.Recordset
    With connRs
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
    .LockType = adLockPessimistic
    .ActiveConnection = connWTC

    End With

    this is the getrecordSet sub

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    No error would be generated unless the RS is STILL open.

    I only said REopen because if it is a move next function used more than once then it keeps opening the RS a new, hence the phrase REopen (as in open again).

    What you could do is record the Absolute page number before you close it then when you open it the second time just add one to that go there and then close.

  7. #7
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    I would change it to something like this instead.
    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3.     If connRs Is Nothing Then
    4.         getRecordSet
    5.     End If
    6.    
    7.     Text1.Text = connRs!UserID
    8.     Text2.Text = connRs!password
    9.     Text3.Text = connRs!userRole
    10.    
    11.     connRs.MoveNext
    12. End Sub
    13.  
    14.  
    15. Public Sub getRecordSet()
    16.     Call Connect 'connection string setup
    17.     Set connRs = New ADODB.Recordset
    18.    
    19.     With connRs
    20.         .CursorLocation = adUseClient
    21.         .CursorType = adOpenStatic
    22.         .LockType = adLockPessimistic
    23.         .ActiveConnection = connWTC
    24.         .Source = "Select * From Users"
    25.         .Open
    26.         .MoveFirst
    27.     End With
    28. End Sub

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