'================================
'===== Pulsanti frame Trova =====
'================================
Private Sub cmdIniziaRicerca_Click()
Dim Ctrl As Control
Dim lCampo As Long
Dim lRif As Long
Dim C As Range
Dim Rng As Range
Dim lUltRiga As Long
lCampo = 0
With Me
With .frSelezionaCampo
For Each Ctrl In .Controls
If Ctrl.Value = True Then
lCampo = Mid(Ctrl.Name, _
4, Len(Ctrl.Name))
End If
Next
End With
If .txtRicerca <> "" And lCampo <> 0 Then
lUltRiga = sh.Range( _
"A" & Rows.Count).End(xlUp).Row
Set Rng = sh.Range("A2:V" & lUltRiga)
For Each C In Rng.Range( _
CELLS(1, lCampo), _
CELLS(lUltRiga, lCampo))
If C.Value = .txtRicerca.Text Then
lRif = 4 - lCampo
.txtID.Value = sh.CELLS(C.Row, 1).Value
.TxtCause.Value = sh.CELLS(C.Row, 2).Value
.txtldv.Value = sh.CELLS(C.Row, 3).Value
.txtInvoice.Value = sh.CELLS(C.Row, 4).Value
.txtawb.Value = sh.CELLS(C.Row, 5).Value
.TxtDatum.Value = sh.CELLS(C.Row, 6).Value
.txtiva.Value = sh.CELLS(C.Row, 7).Value
.Texdatappp.Value = sh.CELLS(C.Row, 8).Value
.Txtdataprat.Value = sh.CELLS(C.Row, 9).Value
.cbodebtor.Value = sh.CELLS(C.Row, 10).Value
.cboanno.Value = sh.CELLS(C.Row, 12).Value
.txtimporto.Value = sh.CELLS(C.Row, 11).Value
.cbocontenuto.Value = sh.CELLS(C.Row, 13).Value
.cbomercato.Value = sh.CELLS(C.Row, 14).Value
.cbopartner.Value = sh.CELLS(C.Row, 15).Value
.cbonazione.Value = sh.CELLS(C.Row, 16).Value
.txtposizione.Value = sh.CELLS(C.Row, 17).Value
.cbostatus.Value = sh.CELLS(C.Row, 18).Value
.txtnote.Value = sh.CELLS(C.Row, 20).Value
.cboliability.Value = sh.CELLS(C.Row, 19).Value
.Txtstart.Value = sh.CELLS(C.Row, 21).Value
.txtend.Value = sh.CELLS(C.Row, 22).Value
lRigaAttiva = C.Row
lRigaValoreTrovato = C.Row
Exit For
End If
Next
Else
MsgBox "No data or field selected", _
vbOKOnly, "Attention"
End If
End With
With Me.txtiva
.Value = Format(.Text, "00000000000")
End With
With Me.TxtDatum
.Value = Format(.Text, "dd/mm/yyyy")
End With
With Me.txtimporto
.Value = Format(.Text, "€ #,##0.00")
End With
Set Ctrl = Nothing
Set C = Nothing
Set Rng = Nothing
End Sub |