My VB.Net project is connected with MS Access. Whenever input in VB, it will save in Access. I don't have any problem with textbox but I don't know what to do with checkbox and radiobutton.
I want, when checkbox or radiobutton is checked in VB, it will checked also in Access.
This is my code for textbox:

Dim con As New OleDb.OleDbConnection
    Dim ds As New DataSet
    Dim da As OleDb.OleDbDataAdapter
    Dim sql As String
    Dim inc As Integer

Private Sub AddButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddButton.Click

        con.ConnectionString = "PROVIDER=Microsoft.Jet.Oledb.4.0; Data source =C:\Documents and Settings\~LaiLi~\My Documents\Visual Studio 2005\Projects\Party\Party\bin\Debug\Party.mdb"
        sql = "SELECT * FROM Planner"
        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(ds, "Planner")
        Dim cb As New OleDb.OleDbCommandBuilder(da)
        Dim dsnewrow As DataRow

If Not DoesAccountExist(EventComboBox.Text) Then
                dsnewrow = ds.Tables("Planner").NewRow()

                dsnewrow.Item("EventName") = EventComboBox.Text
                dsnewrow.Item("ClientName") = ClientTextBox.Text
                dsnewrow.Item("VenueName") = VenueTextBox.Text

                da.Update(ds, "Planner")

                MessageBox.Show("Data saved!")
                With Me
                    EventComboBox.DisplayMember = 0
                End With
End If
End Sub

What should I change to make Access save checkbox and radiobutton?

Recommended Answers

All 4 Replies

On Access you must define the fields as Yes/No


dsnewrow.Item("Urgent") = checkBoxUrgent.Checked
dsnewrow.Item("Option1") = radioButton1.Checked

Hope this helps

It worked. Thank you.

please help me with that kind of problem .. i already made the field with yes/no
but i dont know how to connect the radiobutton on it.

If RadioButton1.Checked = True Then

DataGridView1.Item(5, DataGridView1.CurrentRow.Index).Value = True

RadioButton1.Checked = False
End If

can you write the code for radiobutton, i like to save it in ms access

for example the radiobutton is male and female, when i clicked the male , in access , both are saved .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.