MUKESHY12390
Well-known Member
- Joined
- Sep 18, 2012
- Messages
- 901
- Office Version
- 2013
- 2011
- 2010
- 2007
- Platform
- 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
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