Private Sub DataGrid1_DblClick()
Dim lngR As Long
Dim Clone_Rs As ADODB.Recordset
Dim strFilter As String
lngR = CLng(DataGrid1.Row + 1)
On Error Resume Next
Adodc1.Refresh: Adodc2.Refresh
Set Clone_Rs = Adodc2.Recordset
Adodc1.Recordset.AbsolutePosition = lngR
strFilter = "code = '" & Adodc1.Recordset.Fields(0) & "' AND reciptno = " & Adodc1.Recordset.Fields(1)
Clone_Rs.Filter = strFilter
If Clone_Rs.EOF Or Clone_Rs.BOF Then
Adodc2.Recordset.MoveMax
Adodc2.Recordset.MoveNext
Else
Adodc2.Recordset.Bookmark = Clone_Rs.Bookmark
End If
frmPurchaseDetails.txtfornecedor.Text = DataGrid1.Columns(3)
frmPurchaseDetails.cbocfop.Text = Adodc1.Recordset.Fields(6)
frmPurchaseDetails.cboespecie.Text = DataGrid1.Columns(3)
frmPurchaseDetails.cbopgto.Text = IIf(DataGrid1.Columns(4) = "0", "a Vista", "a Prazo")
frmPurchaseDetails.txtcpf.Text = Adodc1.Recordset.Fields(7)
frmPurchaseDetails.txtReceipt.Text = DataGrid1.Columns(1)
frmPurchaseDetails.txtPurchaseCode.Text = DataGrid1.Columns(0)
frmPurchaseDetails.dtpDate.Value = DataGrid1.Columns(2)
frmPurchaseDetails.grdPurchase.TextMatrix(idxRow, 1) = Adodc2.Recordset.Fields(0)
frmPurchaseDetails.grdPurchase.TextMatrix(idxRow, 2) = Adodc2.Recordset.Fields(1)
frmPurchaseDetails.grdPurchase.TextMatrix(idxRow, 3) = Adodc2.Recordset.Fields(5)
frmPurchaseDetails.grdPurchase.TextMatrix(idxRow, 4) = Adodc2.Recordset.Fields(6)
frmPurchaseDetails.grdPurchase.TextMatrix(idxRow, 5) = Adodc2.Recordset.Fields(9)
frmPurchaseDetails.txtTotal = Format$(CCur((Val(frmPurchaseDetails.txtTotal)) + Adodc2.Recordset.Fields(7)), "########0.00")
Filter_Rs.Close
Unload frmPesquisaNFCompra
End Sub