Reputation: 317
This is not working.
Me.Textbox = Me.ListBox.ListCount
It say;
What code should I put into it? When I load the Form, it should display the count of the ListBox's items on the textbox.
Upvotes: 0
Views: 4703
Reputation: 333
There is nothing wrong with the syntax of your code. So the first thing that should be looked at is the names of your listbox and textbox. By default ms-access calls them list and text followed by a number. To find the assigned name go to their property and then the other tab and name of the control is at the top of the list.
Also make sure that you are running the code from the form's onload event. You may try the forms oncurrent event to see if it makes ant difence
Upvotes: 1
Reputation: 29332
The TextBox and ListBox are not the names of the variables, but oh the classes. When you instantiate an object of Textbox (or ListBox), VB gives it the name TexBox1 (or ListBox1). You can change this name in the properties window. I suppose what you have now are TextBox1 and ListBox1.
Me.Textbox1 = Me.ListBox1.ListCount
Upvotes: 1