problema con consulta sql!!!

miguel
17 de Junio del 2003
hola maestros les traigo una duda al intentar una consulta me da "error 3061 , pocos parametros se espera 1" , gracias....

Dim DB As DAO.Database
Private RS As DAO.Recordset




Private Sub Command10_Click()
Unload Me
End Sub

Private Sub Command6_Click()
repocisionar 2
End Sub

Private Sub Command7_Click()
repocisionar 1
End Sub

Private Sub Command8_Click()


ACEPTAR




End Sub

Private Sub Form_Load()

Set DB = OpenDatabase("C:\miguel\vb6 ftp\AUTOS.MDB")
Set RS = DB.OpenRecordset("AUTOS")





End Sub



Private Sub ACEPTAR()
MsgBox Text14.Text
Dim SQL As String
Dim PASO As String
PASO = Text14.Text
SQL = "SELECT * FROM AUTOS WHERE PATENTE =" + Text14.Text + " "
Set RS = DB.OpenRecordset(SQL)\'AQUI ME MARCA EL ERROR
If Not (RS.BOF And RS.EOF) Then
MsgBox "registro encontrado"
CARGARCONTROLES
Else
MsgBox "no encontrado"

End If



HABILITAREDICION





End Sub

Private Sub CARGARCONTROLES()
If Not RS.EOF And Not RS.BOF Then

Text1.Text = RS!TIPO
Text2.Text = RS!MARCA
Text3.Text = RS!MODELO
Text4.Text = RS!año
Text5.Text = RS!Color
Else

Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End If


End Sub

Private Sub HABILITAREDICION()
Text14.Enabled = False


End Sub

Private Sub repocisionar(ByVal movimientos As Integer)
Select Case movimientos
Case 1
If Not RS.EOF Then RS.MoveNext
Case 2
If Not RS.BOF Then RS.MovePrevious
End Select
CARGARCONTROLES

End Sub

angeles
17 de Junio del 2003
Quita las barras en la consulta:

Private Sub Form_Load()
Set DB = OpenDatabase("C:miguelvb6 ftpAUTOS.MDB")
Set RS = DB.OpenRecordset("AUTOS")
End Sub

Private Sub ACEPTAR()
MsgBox Text14.Text
Dim SQL As String
Dim PASO As String
PASO = Text14.Text
'Si el campo PATENTE es de tipo numérico en la BD:
SQL = "SELECT * FROM AUTOS WHERE PATENTE =" & Text14.Text
'Si no lo es:
SQL = "SELECT * FROM AUTOS WHERE PATENTE ='" & Text14.Text & "'"

Set RS = DB.OpenRecordset(SQL) 'AQUI ME MARCA EL
ERROR
If Not (RS.BOF And RS.EOF) Then
MsgBox "registro encontrado"
CARGARCONTROLES
Else
MsgBox "no encontrado"
End If
Espero que te sirva

Alex
17 de Junio del 2003
Prueba a poner en vez de + un & para concatenar dos strings, aparte, si lo que vas a igualar en la consulta sql es de tipo caracter tiene que ir precedido (el resultado) de \'. fale