PESQUISAR

USUARIO.EXCLUIDOS 01/08/2007 12:36:27
#228788
Pessoal, boa Tarde!!!
preciso de uma rotina semelhante a rotina abiaxo, que quando digitar o numero do voucher no txtpesquisa, e chamar a função abaixo ela pesquisa na tabela o numero do voucher e me retorna os dados!
Porém não consigo formatar a rotina abaixo para tal acontecimento!
Me ajudem!!!

Dim TblVoucherCarimbado As Recordset

Function VoucherCarimbado()
If txtPesquisa.Text = "" Then
MsgBox "entre com o Número do Voucher!", vbInformation, Me.Caption
txtPesquisa.SetFocus
End If

TblVoucherCarimbado.OpenRecordset "Select from TblVoucherCarimbado where Voucher like '" & txtPesquisa.Text & "%' order by Voucher", CpnInfo, adOpenKeyset, adLockReadOnly
If TblVoucherCarimbado.RecordCount = 0 Then
MsgBox "Teste"
txtPesquisa.SetFocus
Exit Sub
End If
Do While Not TblVoucherCarimbado.EOF
Label2.Caption = TblVoucherCarimbado("Data")
Label4.Caption = TblVoucherCarimbado("Horario")
Label6.Caption = TblVoucherCarimbado("Responsavel")
Label8.Caption = TblVoucherCarimbado("Carimbado")
Label10.Caption = TblVoucherCarimbado("DataCarimbo")
Label12.Caption = TblVoucherCarimbado("DataPrevista")
Label17.Caption = TblVoucherCarimbado("Origem")
Label15.Caption = TblVoucherCarimbado("Destino")
Label13.Caption = TblVoucherCarimbado("Valor")
Label26.Caption = TblVoucherCarimbado("ValorDeslocamento")
Label24.Caption = TblVoucherCarimbado("ValorTotal")
Label22.Caption = TblVoucherCarimbado("ValorLiquido")
Label20.Caption = TblVoucherCarimbado("Obs")
Label29.Caption = TblVoucherCarimbado("Pago")
TblVoucherCarimbado.MoveNext
Loop
TblVoucherCarimbado.Close
End Function


Marcelino Neto
RODRIGOGBGOMES 01/08/2007 12:48:28
#228790
Dim TblVoucherCarimbado As Recordset


Function VoucherCarimbado(NumVoucher as String)
If NumVoucher = "" Then
MsgBox "entre com o Número do Voucher!", vbInformation, Me.Caption
txtPesquisa.SetFocus
exit Function
End If

TblVoucherCarimbado.Open "Select * from TblVoucherCarimbado where Voucher like '" & NumVoucher & "' order by Voucher", CpnInfo, adOpenKeyset, adLockReadOnly
If TblVoucherCarimbado.RecordCount = 0 Then
MsgBox "Teste"
txtPesquisa.SetFocus
Exit Sub
End If
Do While Not TblVoucherCarimbado.EOF
Label2.Caption = TblVoucherCarimbado.Fields("Data")
Label4.Caption = TblVoucherCarimbado.Fields("Horario")
Label6.Caption = TblVoucherCarimbado.Fields("Responsavel")
Label8.Caption = TblVoucherCarimbado.Fields("Carimbado")
Label10.Caption = TblVoucherCarimbado.Fields("DataCarimbo")
Label12.Caption = TblVoucherCarimbado.Fields("DataPrevista")
Label17.Caption = TblVoucherCarimbado.Fields("Origem")
Label15.Caption = TblVoucherCarimbado.Fields("Destino")
Label13.Caption = TblVoucherCarimbado.Fields("Valor")
Label26.Caption = TblVoucherCarimbado.Fields("ValorDeslocamento")
Label24.Caption = TblVoucherCarimbado.Fields("ValorTotal")
Label22.Caption = TblVoucherCarimbado.Fields("ValorLiquido")
Label20.Caption = TblVoucherCarimbado.Fields("Obs")
Label29.Caption = TblVoucherCarimbado.Fields("Pago")
TblVoucherCarimbado.MoveNext
Loop
TblVoucherCarimbado.Close
End Function


tenta assim...
pra chamar a função use isso.

VoucherCarimbado txtPesquisa.Text

SILVERDRAGON 01/08/2007 12:51:09
#228792
Resposta escolhida
Tenta isso:

Function VoucherCarimbado()
If txtPesquisa.Text = "" Then
MsgBox "entre com o Número do Voucher!", vbInformation, Me.Caption
txtPesquisa.SetFocus
End If

SeuRecordset.Open "Select from TblVoucherCarimbado where Voucher like '" & txtPesquisa.Text & "%' order by Voucher", CpnInfo, adOpenKeyset, adLockReadOnly
If TblVoucherCarimbado.RecordCount = 0 Then
MsgBox "Teste"
txtPesquisa.SetFocus
Exit Sub
End If
Do While Not TblVoucherCarimbado.EOF
Label2.Caption = TblVoucherCarimbado("Data")
Label4.Caption = TblVoucherCarimbado("Horario")
Label6.Caption = TblVoucherCarimbado("Responsavel")
Label8.Caption = TblVoucherCarimbado("Carimbado")
Label10.Caption = TblVoucherCarimbado("DataCarimbo")
Label12.Caption = TblVoucherCarimbado("DataPrevista")
Label17.Caption = TblVoucherCarimbado("Origem")
Label15.Caption = TblVoucherCarimbado("Destino")
Label13.Caption = TblVoucherCarimbado("Valor")
Label26.Caption = TblVoucherCarimbado("ValorDeslocamento")
Label24.Caption = TblVoucherCarimbado("ValorTotal")
Label22.Caption = TblVoucherCarimbado("ValorLiquido")
Label20.Caption = TblVoucherCarimbado("Obs")
Label29.Caption = TblVoucherCarimbado("Pago")
TblVoucherCarimbado.MoveNext
Loop
TblVoucherCarimbado.Close
End Function


Tópico encerrado , respostas não são mais permitidas