Reputation: 1
I have queries, tables, and forms in Microsoft Access. I have a list box and a button in one of my forms. When I click the button, the data in the list box should appear. But it doesn't.
button OnClick code:
Private Sub btn_Click()
Me.listt.RowSource = "SELECT * FROM shartnomachilar"
End Sub
I should see the data in the table when I click the button, but it doesn't
Upvotes: -1
Views: 66
Reputation: 37050
Try the following codes.
Private Sub btn_Click()
Me.listt.ColumnCount = CurrentDb.TableDefs("shartnomachilar").Fields.Count
Me.listt.RowSource = "SELECT * FROM shartnomachilar"
End Sub
CurrentDb.TableDefs("shartnomachilar").Fields.Count
this line will count fields (means, columns) in the table and will display those columns in listbox control.
Listbox control has default property Row Source Type as Table/Query. If it is not then set this property as Table/Query.
Upvotes: 0