Listbox update on command

J

Jennifer

Hello guru's,
I have a listbox displayed in a form filled through the row source in
properties (a named offset). When the user adds data to a textbox then hits
the add button it goes to the database. The form remains open and i would
like to have the listbox update with the new information immediately instead
of showing the added data when i reactivate the form. Help.
 
G

Greg Wilson

My take on "a named offset" was that your database is a *dynamic named range*
and that the rowsource is the same (references by name). This may be
completely wrong. However, your post suggests that adding to the database
(row source) is not the problem. Just updating the listbox to reflect it. All
you need to do to get the list box to update is to just state that the
rowsource is the name of the range. Simplified example code:

Private Sub CommandButton1_Click()
With Range("Database")
.Cells(.Cells.Count + 1).Value = TextBox1.Text
End With
ListBox1.RowSource = "Database"
End Sub

Regards,
Greg
 

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