Loading...

How to create basic data Entry form in VBA & Integrate with MS-Access Database.

743 56________

HI All,

My Name is Aakash, In this video i have told about how we can create basic data entry form in VAB & integrate with MS-Access database..

Below is the code which you can take for understaing.

Private Sub CommandButton1_Click()

Dim Cnn As New ADODB.Connection, Rst As New Recordset, K As Integer
Cnn.Provider = "Microsoft.ACE.OLEDB.12.0"
Cnn.Open "c:\Users\computers\Desktop\MS-Access\Data.accdb"
Rst.Open "Sheet4", Cnn, adOpenDynamic, adLockOptimistic

Rst.AddNew
Rst.Fields(0).Value = Me.TextBox1.Value
Rst.Fields(1).Value = Me.TextBox2.Value
Rst.Fields(2).Value = Me.TextBox3.Value
Rst.Fields(3).Value = Me.TextBox4.Value
Rst.Fields(4).Value = Me.TextBox5.Value
Rst.Fields(5).Value = Me.TextBox6.Value
Rst.Fields(6).Value = Me.TextBox7.Value
Rst.Update

Cnn.Close

Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox5.Value = ""
Me.TextBox6.Value = ""
Me.TextBox7.Value = ""

MsgBox "Data saved successfully!", vbInformation

End Sub

Any Query if you have you can share that on : Akusharma42@gmail.com

コメント