Dicas

Pesquisa quando o campo for numérico:
Dim sSQL as String
sSQL = "Select Codigo, Nome, Cidade, Telefone From Clientes Where Codigo=" & txtPesquisa.Text
Set rsCliente = Nothing
rsCliente.Open sSQL, Cnn, adOpenDynamic, adLockOptimistic

Pesquisa quando o campo for alfanumérico pela inicial:
Dim sSQL as String
sSQL = "Select Codigo, Nome, Cidade, Telefone From Clientes Where Nome like '" & txtPesquisa.Text & "%' "
Set rsCliente = Nothing
rsCliente.Open sSQL, Cnn, adOpenDynamic, adLockOptimistic

Pesquisa em qualquer parte do campo
Dim sSQL as String
sSQL = "Select Codigo, Nome, Cidade, Telefone From Clientes Where Nome like '%" & txtPesquisa.Text & "%' "
Set rsCliente = Nothing
rsCliente.Open sSQL, Cnn, adOpenDynamic, adLockOptimistic

Pesquisa quando o campo for alfanumérico exatamente como está no campo:
Dim sSQL as String
sSQL = "Select Codigo, Nome, Cidade, Telefone From Clientes Where Nome= '" & txtPesquisa.Text & "'"
Set rsCliente = Nothing
rsCliente.Open sSQL, Cnn, adOpenDynamic, adLockOptimistic

Pesquisa por data:
Dim sSQL as String
sSQL = "Select * from Receber Where Vencimento Between " & "#" & _
Format(mskDataIni.Text, "yyyy/mm/dd") & "#" & " and " & "#" & Format(mskDataFim.Text, "yyyy/mm/dd") & "#" & "Order By Vencimento"
Set rsReceber = Nothing
rsReceber.Open sSQL, Cnn, adOpenDynamic, adLockOptimistic

 

Hosted by www.Geocities.ws

1