have created a form in which i call other forms from the main form ..
When i click a particular button twice there is an error .. Can anyone help me to solve my problem.. The error is:::
ERROR 3705
"Operation is not allowed when the object is open"...
Here i am l posting the code so that you all may get some idea...
Thanks
When i click a particular button twice there is an error .. Can anyone help me to solve my problem.. The error is:::
ERROR 3705
"Operation is not allowed when the object is open"...
Here i am l posting the code so that you all may get some idea...
Code:
Dim Connection As New ADODB.Connection
Dim Recordset As New ADODB.Recordset
Private Sub cmdAdd_Click()
txtControl.Enabled = True
txtSupply.Enabled = True
txtPieces.Enabled = True
txtQuantity.Enabled = True
txtPrice.Enabled = True
cmdSave.Enabled = True
cmdAdd.Enabled = False
txtControl.SetFocus
End Sub
Private Sub cmdBack_Click()
Unload Me
End Sub
Private Sub cmdSave_Click()
With Recordset
.Open "Select * from tblSupplies", Connection, adOpenStatic, adLockOptimistic, adLockReadOnly
End With
Recordset.AddNew
Recordset.Fields("Control").Value = txtControl.Text
Recordset.Fields("Supplies").Value = txtSupply.Text
Recordset.Fields("Pieces").Value = txtPieces.Text
Recordset.Fields("Quantity").Value = txtQuantity.Text
Recordset.Fields("Price").Value = txtPrice.Text
cmdAdd.Enabled = True
cmdSave.Enabled = False
Recordset.Update
MsgBox "You have successfully added a new record in the database", vbInformation + vbOKOnly
Set Recordset = Nothing
txtControl.Enabled = False
txtSupply.Enabled = False
txtPieces.Enabled = False
txtQuantity.Enabled = False
txtPrice.Enabled = False
End Sub
Private Sub Form_Load()
Connection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\Users\-\Desktop\RIS\DATABASE\RIS.mdb;"
Recordset.CursorLocation = adUseClient
End Sub
Thanks
Comment