Gostaria de agradecer desde já pela atenção!
Seguinte:
No cód do evento afterupdate, abaixo, do "frm_rbpa" tenho a instrução para que quando o "txt_periodo" for preenchido com alguma data que esteja na planilha..então ao mudar o foco txtbox os demais txtbox's: "txt_rpa", "txt_fspa" sejam preenchidos com os demais dados do registro.
faço a chamada deste evento no evento initialize:
Código: Selecionar todos
Private Sub txt_periodo_AfterUpdate()
Dim lngPriLin, lngUltLin, lngLoopLin As Long
Dim datPeriodo As Date
Dim vlrRPA, vlrFSPA As Currency
Dim strbusca As String
If txt_Peridodo = "" Or IsEmpty(txt_periodo) Then Exit Sub
'If txt_rpa = "" Or IsEmpty(txt_rpa) Then Exit Sub
'If txt_fspa = "" Or IsEmpty(txt_fspa) Then Exit Sub
lngPriLin = 2
datPeriodo = CDate(txt_periodo.Text)
vlrRPA = txt_rpa.Text
vlrFSPA = txt_fspa.Text
With wshComum
lngUltLin = .Cells(.Rows.Count, 2).End(xlUp).Row
For lngLoopLin = lngPriLin To lngUltLin Step 1
strbusca = .Cells(lngLoopLin, 2)
If strbusca = datPeriodo Then
vlrRPA = CCur(.Cells(lngLoopLin, 3))
vlrFSPA = CCur(.Cells(lngLoopLin, 4))
End If
Next lngLoopLin
End With
End Sub