Getting runtime error # 3265

"IItem cannot be found in the collection.."

Page 1 of 1

3 Replies - 10615 Views - Last Post: 14 September 2010 - 10:10 AM Rate Topic: -----

#1 purple_jay   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 29
  • Joined: 02-December 08

Getting runtime error # 3265

Posted 14 September 2010 - 07:27 AM

hi!

Im trying to create a patient file maintenance program in VB6. I've already managed to add and delete records through the program. However, when I'm at the 'Edit Record' part already, I'm now getting the run-time error: 3265 where it says that Item cannot be found in the collection corresponding to the requested name or ordinal I'm guessing that one fields doesnt match or something. Although it's quite impossible since I'm just editing the same record I just added.

I'm using ListView and it loads the PID, LastName and First Name from my database.


What seems to be the problem? :/

Here's my code;

for the LoadRecord Function, where it loads all the necessary attributes to each textbox:
Sub LoadRecord()
If rs.RecordCount <> 0 Then
    txtPID = rs.Fields("PID")
    txtLName = rs.Fields("PLName")
    txtFName = rs.Fields("PFName")
    txtMI = rs.Fields("PMInitial")
    txtAddress = rs.Fields("PAddress") ' this is where the Debugger highlights my error
    txtCNo = rs.Fields("PContact")
    dtpDOB.Value = rs.Fields("PBirth")
    txtAge = rs.Fields("PAge")
    cmbSex = rs.Fields("PSex")
    cmbCS = rs.Fields("PCivilS")
Else
 Msgbox "No record to display", vbOkOnly
End if
End Sub




Code for clicking 'Edit Button'
Private Sub cmdEdit_Click()
Mode = "Edit"
With rs
        .MoveFirst
        .Find "PID = '" & lvPtRecords.SelectedItem.Text & "'"
        fraEdit.Visible = True
End With
LoadRecord
lvPtRecords.Enabled = False
End Sub



Form Load:
Private Sub Form_Load()
GetRS
Set rs = Nothing
rs.CursorLocation = adUseClient
rs.Open "SELECT PID, PLName, PFName, PMInitial FROM PRecord", cn, 3, 2
LoadPtRecords ' Loads the database in my ListView
End Sub




Will be forever grateful for all the help that I can get..
Thanks

This post has been edited by purple_jay: 14 September 2010 - 07:28 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Getting runtime error # 3265

#2 raziel_   User is offline

  • Like a lollipop
  • member icon

Reputation: 469
  • View blog
  • Posts: 4,280
  • Joined: 25-March 09

Re: Getting runtime error # 3265

Posted 14 September 2010 - 08:06 AM

check the names of your fields. perhaps its typo that cause this error.
Was This Post Helpful? 0
  • +
  • -

#3 thava   User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,607
  • Joined: 17-April 07

Re: Getting runtime error # 3265

Posted 14 September 2010 - 08:13 AM

change the form loads query
rs.Open "SELECT * FROM PRecord", cn, 3, 2
LoadPtRecords 


when you mention a field in the recodset it must lie there

(i.e) the query must contains that column
Was This Post Helpful? 1
  • +
  • -

#4 maj3091   User is offline

  • D.I.C Lover
  • member icon

Reputation: 331
  • View blog
  • Posts: 1,999
  • Joined: 26-March 09

Re: Getting runtime error # 3265

Posted 14 September 2010 - 10:10 AM

View Postthava, on 14 September 2010 - 07:13 AM, said:

change the form loads query
rs.Open "SELECT * FROM PRecord", cn, 3, 2
LoadPtRecords 


when you mention a field in the recodset it must lie there

(i.e) the query must contains that column


Spot on....you're only returning a subset of the fields.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1