Object Required error

aman

Registered User.
Local time
Yesterday, 21:15
Joined
Oct 16, 2008
Messages
1,251
Hi Guys

I am getting runtime error 424, Object required in the following lines of code:
Code:
 Private Sub cboRole_AfterUpdate()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("select * from tblTC_Type where role='" & cboRole.Value & "'")
MsgBox cboRole.Value
 [COLOR=red]Me.cboMDForms.Column(0).Recordset = rs.Fields(0).Value[/COLOR]
 End Sub
Can anyone please help me ?

Thanks
 
you DONT set recordsets to columns.
the combo box.ROWSOURCE gets the recordset/query
the column is a field in this set.
 
You can't set a specific columns value in a combobox that is based on a recordset. At least not that I know of.
You could if your combobox was based on a value list, but that would take some nifty set based programming.
TBH I'm not sure why you would want to do this - if you just want to update a particular field in a record then use an update query. If you want to display the value on a form then set a unbound text box to the value you just found.
 
This is interesting to me as I just found out yesterday that combo boxes and list boxes have a recordset property. In Mr. aman's code you can put

Code:
Set Me.cboMDForms.Recordset = rs

And the code runs but I can't figure out what that is suppose to do. How do you use combo box recordsets?

@aman Hope you don't mind me hitching a ride on your thread.
 

Users who are viewing this thread

Back
Top Bottom