Update_Table

MUKESHY12390

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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,017
Messages
5,834,960
Members
430,330
Latest member
drAli77

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
Top