Obrigado pela força, cara! Segue o codigo. o primeiro faz a inserção do bd e o segundo atualiza o grid. ============================================== Private Sub cmdSalvaMB_Click()
'On Error GoTo ErrNro
If ConsisteMB = False Then
Exit Sub
End If
If ConectaServidor() Then
Set rstRs = New ADODB.Recordset
iSQl = ""
iSQl = "SELECT * FROM TABPPPRSP_MB"
rstRs.Open iSQl, DBConn, adOpenKeyset, adLockOptimistic
With rstRs
.AddNew
rstRs!IDMB = IDMB.Text
rstRs!mbCRMCREA = mbCRMCREA.Text
rstRs!mbCtrlClasse = mbCtrlClasse.Text
rstRs!mbNIT = mbNIT.Text
rstRs!mbNome = mbNome.Text
rstRs!mbPeridoAte = mbPeridoAte.Text
rstRs!mbPeridoDe = mbPeridoDe.Text
rstRs!funID = funID.Text
.Update
Call BuscaMBGrid(funID)
cmdIncluiRMB.Enabled = True
cmdSalvaMB.Enabled = False
End With
rstRs.Close
End If
Exit Sub
ErrNro:
MsgBox "Falha na exclusão do registro!", vbInformation
End Sub
--------------------------------------------------------------------------
Sub BuscaMBGrid(NroFUN As Integer)
On Error GoTo Err:
GridRMB.Clear
GridRMB.Height = 2115
GridRMB.Top = 240
GridRMB.Visible = True
GridRMB.ZOrder
If ConectaServidor() Then
Set psqRs = New ADODB.Recordset
iSQl = ""
iSQl = "SELECT IDMB, mbPeridoDe, mbNome, mbPeridoAte, funID FROM TABPPPRSP_MB WHERE funID = " & NroFUN
psqRs.Open iSQl, DBConn, adOpenKeyset, adLockOptimistic
If Not psqRs.EOF = True Then
GridRMB.Cols = 6
GridRMB.Rows = psqRs.RecordCount + 2
i = 1
Do While Not psqRs.EOF
GridRMB.TextMatrix(i, 0) = ""
GridRMB.TextMatrix(i, 1) = psqRs(0)
GridRMB.TextMatrix(i, 2) = IIf(IsNull(psqRs(1)), "", psqRs(1))
GridRMB.TextMatrix(i, 3) = IIf(IsNull(psqRs(2)), "", psqRs(2))
GridRMB.TextMatrix(i, 4) = IIf(IsNull(psqRs(3)), "", psqRs(3))
GridRMB.TextMatrix(i, 5) = IIf(IsNull(psqRs(4)), "", psqRs(4))
i = i + 1
psqRs.MoveNext
Loop
With GridRMB
.ColWidth(0) = 250
.ColWidth(1) = 0
.ColWidth(2) = 1200
.ColWidth(3) = 5400
.ColWidth(4) = 1200
.ColWidth(5) = 700
.TextMatrix(0, 1) = "Nro"
.TextMatrix(0, 2) = "Dta Inicio"
.TextMatrix(0, 3) = "Nome"
.TextMatrix(0, 4) = "Dta.Final"
.TextMatrix(0, 5) = "FunID"
End With
psqRs.Close
Else
With GridRMB
.Clear
.Cols = 6
.Rows = 2
.ColWidth(0) = 250
.ColWidth(1) = 0
.ColWidth(2) = 1200
.ColWidth(3) = 5400
.ColWidth(4) = 1200
.ColWidth(5) = 700
.TextMatrix(0, 1) = "Nro"
.TextMatrix(0, 2) = "Dta Inicio"
.TextMatrix(0, 3) = "Nome"
.TextMatrix(0, 4) = "Dta.Final"
.TextMatrix(0, 5) = "FunID"
End With
psqRs.Close
End If
End If
Exit Sub
Err:
MsgBox Err.Description, vbCritical
End Sub