Update_Table

MUKESHY12390

Well-known Member
Joined
Sep 18, 2012
Messages
901
Office Version
  1. 2013
  2. 2011
  3. 2010
  4. 2007
Platform
  1. Windows
Hello.....there

I have created one userform it has two textbox (i.e textbox1 and textbox2) and linked to MS Access file.

but whenever I put some value in textBox and click nothing happen. don't know what went wrong.
need help...any help would be appreciate


Code:
Private Sub CB_Save_Click()
Dim rst As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim myconn  As String






myconn = "C:\Users\mks\Desktop\ADOB.connection\mks_DB.mdb"  ''' ms access file location


Set cnn = New ADODB.Connection


With cnn
.Provider = "Microsoft.jet.OLEDB.4.0"
.Open myconn
End With


Set rst = New ADODB.Recordset


rst.CursorLocation = adUseServer


rst.Open Source:="Personal_Details", _
ActiveConnection:=cnn, _
CursorType:=adOpenDynamic, _
LockType:=adLockBatchOptimistic, _
Options:=adCmdTable
rst.AddNew




rst.Fields("ID") = UserForm1.TextBox1
rst.Fields("Fname") = UserForm1.TextBox2.Value
rst.Update


rst.Close
cnn.Close





TextBox1 = ""
TextBox2 = ""

End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,214,998
Messages
6,122,639
Members
449,093
Latest member
Ahmad123098

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top