Hey guys, I've been trying to figure this out for a couple days now and haven't gotten very far.
I have a database of table #'s (for a room in a restaurant) that I need to generate buttons for. The database is tables.mdb, and the table I want to generate buttons from is tabnum.
Code:
Public Function disptables()
Dim x As Integer
x = 5
Dim NB As New Button
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
con.Open()
Dim da As New OleDb.OleDbDataAdapter("select TabNum from TabNum", con)
da.Fill(dt)
For Each DataRow In dt.Rows
x = x + 20
NB.Left = 5
NB.Top = 5 + x
NB.Name = "TBL" & DataRow(0)
NB.Text = "TABLE " & DataRow(0)
Me.Controls.Add(NB)
Next
con.Close()
Return True
End Function
This code only generates a button for the last table number in the DB. What am I doing wrong?