fdelator | |
|
Re: Ayuda en consultas en vb y between - 2008-05-15 04:42 - Respuesta 4
Option Explicit
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim Rx As Long
Dim xCount As Integer
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub buscar_Click()
On Error Resume Next
Dim fechaini As Date
Dim fechafin As Date
Dim Campo As String
Dim texto As String
fechaini = DTPicker1
fechafin = DTPicker2
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.CursorLocation = adUseClient
conn.ConnectionString = dame_cadena_conexion
conn.Open
'rs.Open "SELECT * FROM registros WHERE " & Campo & " like '%" & texto & "%'", conn
' If Campo = "fecha" Then
rs.Open "SELECT * from registros where fecha between '2006-04-01' and '2006-04-03'", conn
'rs.Open "select * from registros where fecha between 'fechaini' and 'fechafin'"
' Verificar si hubo registros
If rs.RecordCount > 0 Then
' Mover el puntero al Inicio de los Resultados
rs.MoveFirst
Do
Set DataGrid1.DataSource = rs
rs.MoveNext
Loop Until rs.EOF
'rs.Requery
ShowGrid
Else
MsgBox "No se ha encontrado ningúna coincidencia.", vbOKOnly + vbInformation, "-: HUELLA DIGITAL :-"
On Error GoTo DBerror
Rx = 0
ShowGrid
MostrarDatos
Exit Sub
DBerror:
ShowGrid
MostrarDatos
End If
'End If
End Sub
gracias | |
|
|