i have a table created in access database i.e mytable
this table has fields as A, B, C, D ,E , F, G , H , I , J , K, L, M , N, O, P, Q, R, S
this field names are just to practice
now i have written a code on userform button so that when i hit the button data gets added to table
below is the code
this table has fields as A, B, C, D ,E , F, G , H , I , J , K, L, M , N, O, P, Q, R, S
this field names are just to practice
now i have written a code on userform button so that when i hit the button data gets added to table
below is the code
VBA Code:
Private Sub CommandButton3_Click()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim path As String, btext As String, dtext As String
Dim etext As String, ptext As String, stext As String
btext = TextBox6.Text
dtext = TextBox7.Text
etext = TextBox3.Text
ptext = TextBox4.Text
stext = TextBox5.Text
path = "C:\Users\Documents\demo.accdb"
Set conn = New ADODB.Connection
conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & path
Set rs = New ADODB.Recordset
Sql = "INSERT INTO mytable([B], [D], [E], [P], [S],)values(" & btext & " , " & dtext & " , " & etext & " , " & ptext & " , " & stext & ")"
conn.Execute Sql
End Sub