Adding To A Listbox

R

Robert Wainwright

I am trying to add a value to listbox that is populated by
a query (The value is not in the query). In VB I believe
the command is simply additem. This command does not
appear to be available in Access 97 VBA. My orginal
thought was use the list count command and then use the
additem command to add a value to a list box that is not
in my query. If someone has a solution for me I will be
in your debt.

thanks,
Robert
 
J

JohnFol

If the data source for the listbox is a query (not possible in VB) you need
to add the record to the tables that feed the query. For example if the
query is
"Select * from MyTable"

...you will need to add the data to "MyTable"
 
G

Gerard Bijl

Instead of using a listbox, you'd better use a combobox. In the data
properties you make sure

that "Limit to list" is Yes, then create an event procedure "On Not in
List". For example:



Private Sub cboTest_NotInList(NewData As String, Response As Integer)

Response = MsgBox("hello, the item " & NewData & " is not in the list !")

Response = acDataErrContinue

End Sub

Instead of the message you could add a function, which starts a form to add
the info to a table (or

add the info automatically).



Gerard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top