Pessoal é possivel ao selecionar um celula no grid trazer em uma mesagem box valores de outro campo da tabela relacionado a esta celula ???
Segue codigo que uso para abastecer a grid:
On Error GoTo Trata_Erro
Me.MousePointer = 11
Set BancoDeDados = OpenDatabase(App.Path & "salao.MDB", False)
Set TBDados = BancoDeDados.OpenRecordset("select Data,Usuario,sum (valor) from dados Where Data >= #" & Format(DataInicial, "mm/dd/yy") & "# and data<= #" & Format(DataFinal, "mm/dd/yy") & "# and Nome='" & NomeCliente.Text & "' group by Data,Usuario order by data desc")
If Not TBDados.EOF Then
With MSFlexGrid1
.Rows = 1
.Cols = 4
.ColWidth(0) = 0
.ColWidth(1) = 1500
.ColWidth(2) = 2500
.ColWidth(3) = 1500
.MergeCells = flexMergeFree
.MergeCol(2) = True
.TextMatrix(0, 0) = ""
.TextMatrix(0, 1) = "Data"
.TextMatrix(0, 2) = "Usuario"
.TextMatrix(0, 3) = "Valor"
End With
i = 1
Do While Not TBDados.EOF
With MSFlexGrid1
.Rows = i + 1
.ColAlignment(0) = flexAlignCenterCenter ' alinha coluna
.TextMatrix(i, 0) = i - 0 ' autonumeração colocar zero para poder começar com 1
.ColAlignment(1) = flexAlignCenterCenter
.TextMatrix(i, 1) = TBDados(0)
.ColAlignment(2) = flexAlignCenterCenter
.TextMatrix(i, 2) = TBDados(1)
.ColAlignment(3) = flexAlignRightCenter
.TextMatrix(i, 3) = Format(TBDados(2), "Currency")
.Col = 3
.Row = i
.CellForeColor = vbRed
.CellFontBold = True
End With
i = i + 1
SomaColuna = SomaColuna + TBDados(2)
TBDados.MoveNext
Loop
' Textbox com o total da coluna
Saldo.Text = Format(SomaColuna, "currency")
End If
FlexCores &HFFFFFF, &HC0FFFF
Me.MousePointer = 0
Exit Sub
Trata_Erro:
MsgBox "Você Selecionou DADOS INVÁLIDOS!!!!"