Ok, i have this form which contains a Datagrid control, i have fix the 1st problem i encountered which is how to connect it to my Dbase to display the content of one of my tables.
Now my problem is, i cant delete records in my Dbase thru selecting it in the Datagrid directly then pressing my Delete command button.
I get the error "OPERATION IS NOT ALLOWED WHEN THE OBJECT IS CLOSED".
I know it has something to do with my Dbase connection code/s, but cant really figure it out.
Heres my form pic:
And heres my code for the Delete Command Button:
Private Sub cmdDelete_Click() On Error GoTo err Dim intYN Set rs = New ADODB.Recordset With rs If .State = adStateOpen Then .Close intYN = MsgBox("You are about to delete a record." & vbCrLf & _ "If you click Yes, you won't be able to undo this delete operation." & _ vbCrLf & vbCrLf & _ "Are you sure you want to delete this record?", vbQuestion + vbYesNo, "Confirm Delete") If intYN = vbNo Then Exit Sub Dbconn.Execute "Delete From Users where UserName = DataGrid1.Text" Call GetUsers txtName.Text = "" txtPass.Text = "" txtConfirm.Text = "" cboPriv.Text = "" MsgBox "The Record has been deleted.", vbInformation Exit Sub err: MsgBox err.Description, vbCritical End With End Sub
I think the problem is in Line 24 (i think)..
Can u check it? Thanks