try the changes below
Code:
Option Explicit
Dim conn As New ADODB.Connection
Dim cmdCommand As New ADODB.Command
Dim rec As New ADODB.Recordset
Private Function connect()
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\" & "db1.mdb;Mode=Read|Write"
conn.CursorLocation = adUseClient
conn.Open
cmdCommand.ActiveConnection = conn
cmdCommand.CommandType = adCmdText
rec.CursorType = adOpenDynamic
rec.CursorLocation = adUseClient
rec.LockType = adLockOptimistic
End Function
Private Sub Form_Load()
connect
End Sub
Private Sub Command1_Click()
cmdCommand.CommandText = "SELECT * FROM table1;"
rec.Open cmdCommand
rec.AddNew
rec.Fields(1) = Text1.Text
rec.Fields(2) = Text2.Text
rec.Fields(3) = Text3.Text
rec.Fields(4) = Text4.Text
rec.Update
'If Not rec.EOF Then rec.MoveNext
MsgBox "record stored"
rec.Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
conn.Close
End Sub
Private Sub Text2_Click()
Form1.Text2.Text = Val(Form1.Text1.Text) * 1#
End Sub
Private Sub Text3_Click()
Form1.Text3.Text = Val(Form1.Text1.Text)
End Sub
Private Sub Text4_Click()
Form1.Text4.Text = Val(Form1.Text2.Text)
End Sub