Listbox update on command

  • Thread starter Thread starter Jennifer
  • Start date Start date
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.
 
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
 
Back
Top