Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListBox properties are not working right!

Status
Not open for further replies.

TheRealDeal

Technical User
Nov 16, 2001
187
US
I keep getting the "Method or Data Member not found" when I run this code on the ListCount property.

Someone please help me get past this error.


Dim rst As Recordset, SelectedName As Integer
Set rst = CurrentDb().OpenRecordset("tblStudentClass")

For SelectedName = 0 To chkMultiSelect.ListCount - 1
If chkMultiSelect.Selected(SelectedName) = True Then
rst.AddNew
rst!StudentID = Me.chkMultiSelect.Column(0, SelectedName)
rst!ScheduleID = Me.ScheduleID
rst!Attended = Me.Attended
rst.Update
End If
Next
 
Try Dim rst As Recordset, SelectedName As Long

For some reason, the Long Datatype seems to work. Let me know if it works

VR
 
I changed it, but the error is still there. It keeps bombing out on the LISTCOUNT setting. For some reason, it will not see this as a valid property.
 
This is a shot in the dark, but do you have to initialize listcount in any way? I've seen a lot of people doing movelast and movefirst before using recordcount..

This being said, I only have 5 weeks of experience in Access / VB so I might be wrong. Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam.
 
I am assuming that you have set the Row Source, Row Source Type, Column Count Properties of the listbox and set the bound column to 1. Also, is the MultiSelect Property set to Extended?

As a check, put a msgBox as follows. Verify the value of the listcount returned as something more than 0.
For SelectedName = 0 To chkMultiSelect.ListCount - 1
MsgBox Me.chkMultiSelect.ListCount --- Add this line
If chkMultiSelect.Selected(SelectedName) = True Then

rst.AddNew
rst!StudentID = Me.chkMultiSelect.Column(0, SelectedName)
rst!ScheduleID = Me.ScheduleID
rst!Attended = Me.Attended
rst.Update
End If
Next

Does the MsgBox return a number >0?

Hope it helps.

VR
 
I placed the MsgBox before the For/Next and I still receive the error "Method or Data Member not found." It can not for some reason, understand the ListCount property.
 
Hi

Do you get the autoselect box of methods and properties when you type the period after rst and chkMultiSelect? If you dont see it, that is your problem.. I suspect that you do not have the right type library in your reference.. Check it out..

VR
 
That is exactly what happens. Do you know what Reference library I should enable?
 
You need the following, in this order:

Visual Basic for Applications
Microsoft Access 9.0 Object Library
Microsoft DAO 3.6 Object Library
Microsoft Visual Basic for Applications Extensibility 5.3

VR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top