editdeleteCode:Dim editRecord As String Dim fnd As String Dim varbookmark varbookmark = adodcReports.Recordset.Bookmark editRecord = InputBox("Please input record ID", "Edit") fnd = "end_of_day_report_id=" & "'" & editRecord & "'" If editRecord = "" Then Exit Sub ElseIf IsNumeric(editRecord) = False Then MsgBox "Please input numbers only.", vbOKOnly, "" Else With adodcReports .Recordset.MoveFirst .Recordset.Find fnd, 0 If .Recordset.EOF = True Then MsgBox "Record not found.", vbOKOnly, "" .Recordset.Bookmark = varbookmark Else txtBranchID.Text = .Recordset.Fields("branch_id") txtTotalSales.Text = .Recordset.Fields("total_sales") txtTotalExpenses.Text = .Recordset.Fields("total_expenses") txtDetailsExpenses.Text = .Recordset.Fields("details_expenses") txtTotalUnsold.Text = .Recordset.Fields("total_unsold") txtRemarks.Text = .Recordset.Fields("remarks") cmdEdit.Enabled = False cmdDelete.Enabled = False cmdAdd.Visible = False cmdSave.Visible = True End If End With End Ifi have a datagrid named dGridEndOfDayReport what i want to know is how can i get the ID just by clicking on the datagrid row. so when i click edit or delete. i will just have confirmation to edit or to delete..Code:Dim fnd As String Dim deleteID As String Dim x As String Dim varbookmark deleteID = InputBox("Input ID", "Delete") fnd = "end_of_day_report_id=" & "'" & deleteID & "'" If deleteID = "" Then Exit Sub ElseIf IsNumeric(deleteID) = False Then MsgBox "Please input numbers only.", vbOKOnly, "" Else With adodcReports .Recordset.MoveFirst .Recordset.Find fnd, 0 If .Recordset.EOF = True Then MsgBox "Report not found.", vbOKOnly, "" Else txtBranchID.Text = .Recordset.Fields("branch_id") txtTotalSales.Text = .Recordset.Fields("total_sales") txtTotalExpenses.Text = .Recordset.Fields("total_expenses") txtDetailsExpenses.Text = .Recordset.Fields("details_expenses") txtTotalUnsold.Text = .Recordset.Fields("total_unsold") txtRemarks.Text = .Recordset.Fields("remarks") x = MsgBox("Are you sure you wish to delete?", vbYesNo, "") If x = vbYes Then .Recordset.Delete .Refresh Adodc1.Refresh Call clearControl(Me) MsgBox "Report Deleted.", vbOKOnly, "" Else Call clearControl(Me) .Recordset.Cancel End If End If End With End If
hope you can help




Reply With Quote