Dim DB As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim RST As New ADODB.Recordset
Dim adoConn As ADODB.Connection

Private Sub Command1_Click()
Adodc1.RecordSource = "INSERT INTO STUDATA(UserName,Password,Course, Gender,Country) Values ('" & TxtUn & "',' " & TxtPw & " ','" & ChkC.ischecked.tostring() & "','" & ChkCC.ischecked.tostring() & "','" & ChkJAVA.ischecked.tostring() & "','" & ChkDOTNET.ischecked.tostring() & "',' " & OptM & "',' " & OptF & "','" & Combo1.Text & "')"

Adodc1.Recordset.AddNew

Adodc1.Recordset.Fields("UserName") = TxtUn
Adodc1.Recordset.Fields("Password") = TxtPw
Adodc1.Recordset.Fields("Course") = ChkC.ischecked.tostring()
Adodc1.Recordset.Fields("Course") = ChkCC.ischecked.tostring()
Adodc1.Recordset.Fields("Course") = ChkJAVA.ischecked.tostring()
Adodc1.Recordset.Fields("Course") = ChkDOTNET.ischecked.tostring()
Adodc1.Recordset.Fields("Gender") = OptM
Adodc1.Recordset.Fields("Gender") = OptF

Adodc1.Recordset.Fields("Country") = Combo1.Text
Adodc1.Recordset.Update
'Next
If MsgBox(" Record is Updated... ", vbInformation + vbOKCancel, "INFO") = vbOK Then
Exit Sub
Else
TxtUn.SetFocus

End If

End Sub

Private Sub Form_Load()
DB.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & App.Path & "\dbs.accdb;Persist Security Info=False"
Adodc1.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=f:\Work\dbs.accdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from STUDATA"
Adodc1.Refresh

End Sub

How does your database table look like? From your current code, you keep overwriting data into the same field - Course. Are courses mutual exclusive? If so, you may need to redesign your database.

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.