Ver Mensaje Individual
  #3 (permalink)  
Antiguo 03/04/2010, 17:31
Avatar de gerardo_goh
gerardo_goh
 
Fecha de Ingreso: noviembre-2008
Mensajes: 107
Antigüedad: 15 años, 6 meses
Puntos: 1
Respuesta: Consulta SQL apaterno,amaterno

Cita:
Iniciado por seba123neo Ver Mensaje
Código vb:
Ver original
  1. vSQL = "SELECT * FROM tbl_nombres WHERE 1=1"
  2.  
  3. If txtapaterno.Text <> "" Then
  4.       vSQL = vSQL & " AND apaterno LIKE '%" & Trim(txtapaterno.Text) & "%'"
  5. End If
  6.  
  7. If txtamaterno.Text <> "" Then
  8.      vSQL = vSQL & " AND amaterno LIKE '%" & Trim(txtamaterno.Text) & "%'"
  9. End If
Hola seba123neo, eres Excelente, he tenido varias respuestas tuyas y la verdad eres muy bueno, agrego mi codigo con la solucion propuesta, muchas gracias, Saludos!!!

Private Sub cmdBuscar_Click()

vSQL = "SELECT * FROM tbl_sicotra WHERE 1=1"

If Text1.Text <> "" Then
vSQL = vSQL & " AND a_paterno LIKE '%" & Trim(Text1.Text) & "%'"
End If

If Text3.Text <> "" Then
vSQL = vSQL & " AND a_materno LIKE '%" & Trim(Text3.Text) & "%'"
End If

With Adodc1
' -- establecer el tipo de Comando ( Consulta SQL )
.CommandType = adCmdText
' -- Asignar la consulta Sql ( seleccionar la tabla de la base de datos DEMO de vb)
.RecordSource = vSQL
' -- refrescar el control
.Refresh
' -- Asignar el recordset al datagrid
Set DataGrid1.DataSource = Adodc1.Recordset
' -- Selecionar el Grid por fila
DataGrid1.MarqueeStyle = dbgHighlightRowRaiseCell
' -- Ocultar el control ADODC
.Visible = False
End With

End Sub