Results 1 to 9 of 9

Thread: [RESOLVED] Run time error 3021

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] Run time error 3021

    Why I got this error message?


    Code:
    Private Sub ListView6_ItemClick(ByVal item As MSComctlLib.ListItem)
    
    tablesys.Close
    tablesys.Open "Select ID,Plot,Kod from yieldraster", consys, adOpenDynamic, adLockOptimistic
    tablesys.MoveFirst
    tablesys.Move CLng(item.Index - 1)
    getID = tablesys.Fields("id").Value
    Text19.Text = tablesys.Fields("Plot").Value & ""
    Text20.Text = tablesys.Fields("Kod").Value & ""
    
    
    End Sub
    Attached Images Attached Images  

  2. #2
    Addicted Member
    Join Date
    Aug 2007
    Location
    India
    Posts
    141

    Re: Run time error 3021

    1) check out the connection state. is it close or open i.e. consys
    2) Before moving to the first record, checkout is there any record in the recordset.
    Do Good. Be Good. The World is yours.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Run time error 3021

    I got this error message when I selecting the last record in the listview. The is not problem is I select next record or first record in listview. I do like this, but still got the error..

    Code:
    Private Sub ListView6_ItemClick(ByVal item As MSComctlLib.ListItem)
    
    
    tablesys.Close
    tablesys.Open "Select ID,Plot,Kod from yieldraster", consys, adOpenDynamic,adLockOptimistic
    tablesys.MoveFirst 
    If Not tablesys.BOF And Not tablesys.EOF Then
    tablesys.Move CLng(item.Index - 1)
    getID = tablesys.Fields("id").Value
    Text19.Text = tablesys.Fields("Plot").Value & ""
    Text20.Text = tablesys.Fields("Kod").Value & ""
    
    Else
    
    MsgBox "No data returned."
    End If
    
    End Sub
    How to check connection state?

  4. #4
    Addicted Member
    Join Date
    Aug 2007
    Location
    India
    Posts
    141

    Re: Run time error 3021

    to check connection state.

    Connestion.state

    adStateOpen
    adStateClose
    Do Good. Be Good. The World is yours.

  5. #5
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Run time error 3021

    Two other possibilities:

    1. No records were returned from the SELECT (EDIT: but I see you're now checking that)
    2. Item.Index = 0 or greater than 1 more than the number of records returned
    Last edited by Doogle; Dec 31st, 2007 at 01:09 AM.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Run time error 3021

    I make a backup .

    I have more then 1000 record in the listview. It work after I delete the records. Now the record in the database is 500 records. Why I got the error message more then 500 record in database?
    Last edited by matrik02; Dec 31st, 2007 at 01:47 AM.

  7. #7
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Run time error 3021

    With the way you're processing the data there has to be a one-to-one relationship between Item.Index and the database records. ie if you have 100 records on the Datatbase, Item.Index cannot be greater than 101.

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Run time error 3021

    I delete the record from 1900 and left the record to 500 records.. It work.. But more than 500 records I got the error.. Why?It suppose work without error for 1900 records.

    Let say, I select the end record "1900", I got the error.. But for 500 records, I select at the end of the records, It work find.

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Run time error 3021

    Build in error trapping.

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