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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListBox AddItem Control error

Status
Not open for further replies.

EarS

Programmer
Jun 5, 2002
26
US
I am trying to use the .AddItem control to put items into a list box. When I try to complile I get the error "method or data member not found". In the object browser I can see that there are 2 listbox's listed. One has this method the other does not. How can I use this control????

Thanks in Advance,

Matt
 
Hi,

I followed the link for the solution and it has nothing to do with .additem not being availble in listboxes, do you have an updated link that I can follow.

Kind Regards

Jason
 
Hi Jason!

You can still use the standard list box control in Access. To add an item to a list in the box you would need to do the following:

If IsNull(Me!YourListBox.Rowsource) = True Then
Me!YourListBox.RowSource = YourNewItem
Else
Me!YourListBox.RowSource = Me!YourListBox.RowSource & ";" & YourNewItem
End If

The code above assumes that YourNewItem is a variable. It is more common in Access for a list box to get its information from a table or query. If that is how you want to do it you can add the item to the table and requery the list box. Alternatively, you can add a boolean field to determine if the item should be included or not (include records only if the boolean is true). Then all you need to do is change the value of the boolean and requery the list box.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top