Automation object error

kate10123

Registered User.
Local time
Today, 07:22
Joined
Jul 31, 2008
Messages
185
Hi All,

Attached is a screenshot of an error message that seems to occur sometimes but then at other times it works fine.

It happens on searching for a student and trying to click on a result to transfer the text to a form.

The code I am using is as follows:

Code:
Private Sub QuickSearch_AfterUpdate()
    
DoCmd.Requery
Me.RecordsetClone.FindFirst "[StudentID] = " & QuickSearch.Column(2)
If Not Me.RecordsetClone.NoMatch Then
   Me.Bookmark = Me.RecordsetClone.Bookmark
Else
   MsgBox "Could not locate [" & Me![QuickSearch] & "]"
End If


Forms!frm_tutor!Tutorial.Form!StudentID = Me.QuickSearch.Column(2)

DoCmd.close acForm, "frmStudentSearch1", acSaveNo

End Sub

I would appreciate any advice on how to solve the problem.

Thanks
 

Attachments

  • error.jpg
    error.jpg
    12.1 KB · Views: 170
Is QuickSearch a combo or listbox?
 
it is a listbox
 
Are you starting your count at 0 (zero)

If your listbox has three columns, their ordinal numbers are 0, 1, 2 & 3
so you need to refer to their ordinal number.I suspect you only have 2 columns in your listbox, by referring to Column(2) which is infact column 3 Access is looking to return something that does not exist.

David
 
Thanks for replying. No Quicksearch.column(2) is referring to the third column in the list.
 
Ok

Does it error when the If statement is True or False or either?

Which line is generating the error?

I suspect it has to do with the fact you are referring to sub forms, I may be wrong, I tend to shy away from them.

David
 
This line is highlighted after debugging the error

Code:
Forms!frm_tutor!Tutorial.Form!StudentID = Me.QuickSearch.Column(2)
 

Users who are viewing this thread

Back
Top Bottom