Ver Mensaje Individual
  #29 (permalink)  
Antiguo 05/03/2008, 13:00
banrey
 
Fecha de Ingreso: septiembre-2007
Mensajes: 318
Antigüedad: 16 años, 8 meses
Puntos: 1
De acuerdo Re: eventos en formulario

en la misma linea de la consulta amigo

RecSQL.Open "SELECT nro_empresa,nombre_empresa FROM rosal WHERE nro_empresa= '" & Val(pasadato.SelectedItem) & "' ", BD, adOpenStatic, adLockOptimistic

pero no veo nada malo en ella a menos que el valor de val(pasadato.selectedItem) no este llegando sera

fijate este seria el codigo completo



Public BD As ADODB.Connection
Public RecSQL As ADODB.Recordset
Dim Vec() As String
Dim i As Integer
Dim count2 As Integer
Private Sub command2_Click()
Set RecSQL = New ADODB.Recordset
RecSQL.Open "SELECT nro_empresa,nombre_empresa FROM rosal WHERE nombre_empresa LIKE '" & Text2 & "%' ", BD, adOpenStatic, adLockOptimistic
If RecSQL.EOF Then
MsgBox "No hay ningún registro en la base de datos", vbExclamation
Else
FillListView
End If
RecSQL.Close
Set RecSQL = Nothing
End Sub

Private Sub Form_Load()
i = 0
On Error GoTo Ver
Set BD = New ADODB.Connection
BD.ConnectionString = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=practica; User=root;Password=123456;Option=3"
BD.Open
Exit Sub
Ver:
MsgBox "Nº de error: " & Err.Number & " | " & Err.Description, vbCritical, "Control de errores"
Err.Clear
End Sub
Private Sub FillListView()
Do While Not RecSQL.EOF
If IsNumeric(RecSQL(0).Value) Then
Set nextLine = pasadato.ListItems.Add(, , Str(RecSQL(0).Value))
Else
Set nextLine = pasadato.ListItems.Add(, , RecSQL(0).Value)
End If
For count2 = 1 To RecSQL.Fields.count - 1
nextLine.SubItems(count2) = "" & RecSQL(count2).Value
Next count2
RecSQL.MoveNext
Loop
End Sub
Private Sub pasadato_DblClick()
RecSQL.Open "SELECT nro_empresa,nombre_empresa FROM rosal WHERE nro_empresa= '" & Val(pasadato.SelectedItem) & "' ", BD, adOpenStatic, adLockOptimistic
If RecSQL.EOF Then
MsgBox "No se consigue"
Else
Form2.Text1.Text = RecSQL.Fields(0)
Form2.Text2.Text = RecSQL.Fields(1)
Form2.Text3.Text = RecSQL.Fields(2)
Form2.Text4.Text = RecSQL.Fields(3)
Form2.Show vbModal
End If
RecSQL.Close
Set RecSQL = Nothing
End Sub