Update_Table

MUKESHY12390

Well-known Member
Joined
Sep 18, 2012
Messages
887
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
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Watch MrExcel Video

Forum statistics

Threads
1,108,960
Messages
5,525,914
Members
409,671
Latest member
nasseralateek

This Week's Hot Topics

Top