naveguito23 de Diciembre del 2003
PreguntaHola a todos y feliz navidad:
Tengo el siguiente problema con una busqueda que realizo en varios controles data(segun elija el usuario de 1 a n,los campos de busqueda son comunes).El error que me da visual es:"Error de sintaxis en la cadena en la expresion de consulta".Este es el codigo que tengo:
Private Sub CmdAceptar2_Click()
For i = 0 To 5
If Data(i).Enabled = True Then
Mconsulta = "select * from " & TABLA(i) & " where'" & Criterio
Data(i).RecordSource = Mconsulta
Data(i).Refresh
RBusc (i)
End If
Next
DBG.Visible = True
End Sub
*Mconsulta es una variable de tipo string,la cual cree para ver lo que cogia la sentencia SQL
Function TABLA(Indice As Integer) As String
Select Case Indice
Case 0
TABLA = "Encoder_Hohner"
Case 1
TABLA = "Encoder_Givi"
Case 2
TABLA = "Encoder_Elgo"
Case 3
TABLA = "Encoder_Posital"
Case 4
TABLA = "Encoder_Scancon"
Case 5
TABLA = "Encoder_Waycon"
End Select
End Function
Function Criterio() As String
Dim MC As String 'usaré esta variable para rellenar el criterio
Dim j As Integer
MC = ""
For j = 0 To 16
If Txt(j) <> "" Then
MC = MC & Campos(i) & " = '" & Txt(j)
End If
Next
If Txtgiro <> "" Then MC = MC & "Giro = '" & Txtgiro & "'And"
If Txtcodigo <> "" Then MC = MC & "Tipcod = '" & Txtcodigo & "'And"
If Txteje <> "" Then MC = MC & "Tipeje = '" & Txteje & "'And"
If Txtbrida <> "" Then MC = MC & "Brida ='" & Txtbrida & "'And"
If Txtconexion <> "" Then MC = MC & "Tipcon ='" & Txtconexion & "'And"
If Txtinterface <> "" Then MC = MC & "Inter ='" & Txtinterface & "'And"
If Txtcircuito <> "" Then MC = MC & "CS ='" & Txtcircuito & "'And"
If Txtfuente <> "" Then MC = MC & "Fuente='" & Txtfuente & "'And"
'Criterio = Trim(Mid(MC, 1, Len(Criterio) - 5))
End Function
Function Campos(Indice As Integer) As String
If Indice = 0 Then Campos = "Refprov"
If Indice = 1 Then Campos = "Ref"
If Indice = 2 Then Campos = "PasC"
If Indice = 3 Then Campos = "Tencod"
If Indice = 4 Then Campos = "Teje"
If Indice = 5 Then Campos = "Cons"
If Indice = 6 Then Campos = "CAxial"
If Indice = 7 Then Campos = "CRadial"
If Indice = 8 Then Campos = "Nrev"
If Indice = 9 Then Campos = "Nimp"
If Indice = 10 Then Campos = "RV"
If Indice = 11 Then Campos = "RC"
If Indice = 12 Then Campos = "FT"
If Indice = 13 Then Campos = "TA"
If Indice = 14 Then Campos = "TF"
If Indice = 15 Then Campos = "IP"
If Indice = 16 Then Campos = "Hum"
End Function
Espero que alguien me pueda ayudar,muchas gracias a todos y prospero año nuevo
Tengo el siguiente problema con una busqueda que realizo en varios controles data(segun elija el usuario de 1 a n,los campos de busqueda son comunes).El error que me da visual es:"Error de sintaxis en la cadena en la expresion de consulta".Este es el codigo que tengo:
Private Sub CmdAceptar2_Click()
For i = 0 To 5
If Data(i).Enabled = True Then
Mconsulta = "select * from " & TABLA(i) & " where'" & Criterio
Data(i).RecordSource = Mconsulta
Data(i).Refresh
RBusc (i)
End If
Next
DBG.Visible = True
End Sub
*Mconsulta es una variable de tipo string,la cual cree para ver lo que cogia la sentencia SQL
Function TABLA(Indice As Integer) As String
Select Case Indice
Case 0
TABLA = "Encoder_Hohner"
Case 1
TABLA = "Encoder_Givi"
Case 2
TABLA = "Encoder_Elgo"
Case 3
TABLA = "Encoder_Posital"
Case 4
TABLA = "Encoder_Scancon"
Case 5
TABLA = "Encoder_Waycon"
End Select
End Function
Function Criterio() As String
Dim MC As String 'usaré esta variable para rellenar el criterio
Dim j As Integer
MC = ""
For j = 0 To 16
If Txt(j) <> "" Then
MC = MC & Campos(i) & " = '" & Txt(j)
End If
Next
If Txtgiro <> "" Then MC = MC & "Giro = '" & Txtgiro & "'And"
If Txtcodigo <> "" Then MC = MC & "Tipcod = '" & Txtcodigo & "'And"
If Txteje <> "" Then MC = MC & "Tipeje = '" & Txteje & "'And"
If Txtbrida <> "" Then MC = MC & "Brida ='" & Txtbrida & "'And"
If Txtconexion <> "" Then MC = MC & "Tipcon ='" & Txtconexion & "'And"
If Txtinterface <> "" Then MC = MC & "Inter ='" & Txtinterface & "'And"
If Txtcircuito <> "" Then MC = MC & "CS ='" & Txtcircuito & "'And"
If Txtfuente <> "" Then MC = MC & "Fuente='" & Txtfuente & "'And"
'Criterio = Trim(Mid(MC, 1, Len(Criterio) - 5))
End Function
Function Campos(Indice As Integer) As String
If Indice = 0 Then Campos = "Refprov"
If Indice = 1 Then Campos = "Ref"
If Indice = 2 Then Campos = "PasC"
If Indice = 3 Then Campos = "Tencod"
If Indice = 4 Then Campos = "Teje"
If Indice = 5 Then Campos = "Cons"
If Indice = 6 Then Campos = "CAxial"
If Indice = 7 Then Campos = "CRadial"
If Indice = 8 Then Campos = "Nrev"
If Indice = 9 Then Campos = "Nimp"
If Indice = 10 Then Campos = "RV"
If Indice = 11 Then Campos = "RC"
If Indice = 12 Then Campos = "FT"
If Indice = 13 Then Campos = "TA"
If Indice = 14 Then Campos = "TF"
If Indice = 15 Then Campos = "IP"
If Indice = 16 Then Campos = "Hum"
End Function
Espero que alguien me pueda ayudar,muchas gracias a todos y prospero año nuevo
