this is my code

dim btn as button
dim rs as dataadapter
rs =" Select * from tbltable1 where status = 'unavailable'", con)
with rs
[i dont know what comes next but i tried this one]
btn.enabled = false
end with

[nothing's change]

[so i tried this one]

dim rs as dataadapter

rs =" Select * from tbltable1 where status = 'unavailable'", con)
with rs

[i dont know what comes next but i tried this one]

button1.enabled = false
button2.enabled = false
button3.enabled = false
button4.enabled = false
end with
[the problem is even the status is available the button is still unclickable]
what is wrong with my code??

[I wanted to call a value in database[ms access]. I have a table named tbltable1 and there are three fields, i,d[autonumber], tablename[text] and status[text].
And i have 4 buttons. Each buttons represents the table name.
what i want to happen is,status [available, unavailable], when the status is = "unavailable"
the button needs to be enabled = false vice versa
please help me.:(
hi, i'm new here and i'm not an advanced user of So i kinda need some help.]

You use a dataAdapter to fill a dataTable (or a dataSet) with the result of the query.
In your case you would end up with a table with 4 rows, each one holding the state of one of the buttons.
You then do a foreach over the dataTable getting the relevant cell and checking its value.
I don't do too mcuh VB.Net stuff these days so this will be just pseudo code but it should help

Dim da as DataAdapter(command object goes here)
Dim dt as DataTable
// set command text for command object
da.Fill(dt)  // get your data
foreach(DataRow row as dt.Rows) 
    // locate cell that holds value you need and enable/disable button

ahh, i thought i can use it without using a cell/table like listview so i tried that code. But my system is like a restaurant , when i click those buttons, the status in the database becomes "unavailable" so the buttons need to be enabled. Please help me with any idea .

You can do it easily if you create the corresponding Table Buttons Dynamically and show on the form. The codes should be

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

Dim CMD As OleDB.OleDbCommand = New OleDb.OleDbCommand("Select * from tbltable1",con)

Dim rd As OldDbDataReader = CMD.ExecuteReader()

If rd.HasRows() Then

    'Declaring the position and size variables
    'for the buttons
    Dim pos As New Point(100, 100)
    Dim sz As New Size(160, 50)

    Do While rd.Read()
        'Declare a button variable
        Dim tbl As New Button

        tbl.Name = "Table" & rd.Items("TableID").ToString()
        tbl.Text = tbl.Name
        tbl.Size = sz
        tbl.Location = pos

        'Adding the button to the form

        'Chaking Status
        If rd.Items("Status") = "Available" Then
            tbl.Enabled = True
            tbl.Enabled = False
        End If

        'Calculation for Horizontal & Vertical 
        'position of the Button.
        Dim xpos As Integer
        Math.DivRem(i, 2, xpos)

        If (xpos = 0) Then
            pos.X = tbl.Left + tbl.Width + 100
            pos.X = 100
            pos.Y = tbl.Top + tbl.Height + 50
        End If

End If


End Sub

Hope it can help you.

it works, thank you @Shark 1,
i declare the i as integer [@ Math.DivRem(i, 2, xpos)]
rd.Item instead of rd.Items

thank you very much for helping me, also to @hericles

@jez9: Sorry, I did the mistakes unwilling ly, because I had no chance to execute the codes.
You do not need to declare any "i". it would be rd.Item("TableID"). You can write the method as

Math.DivRem(Val(rd.Item("TableID")), 2, xpos)

@Shark_1 thank you so much for helping :) , i dont know what to do , so thank you so much , i will try the code