Hola, ya comenté ayer en otro post, que esta intando corregir algunos fallos a una aplicación privada (estoy en las prácticas del cs en una empresa).
El caso es que yo tanto en el ciclo superior como hago cosillas por mi cuenta, uso sintaxis SQL para SQL Server, pero esta aplicación va contra Access y parece ser Access tiene una sintaxis algo diferente y claro, no me entero para que sirven algunas cosas.
Por ejemplo:
Código:
strSQL = ""
strSQL = strSQL & "SELECT "
strSQL = strSQL & " CodClientes.Código & ' ' & CodClientes.Nombre AS Cliente, "
strSQL = strSQL & " InmAlquilerItem.Contrato & '.' & InmAlquilerItem.Número AS Contrato, "
strSQL = strSQL & " InmAlquiler.Referencia AS Obra, "
strSQL = strSQL & " InmAlquiler.Días AS Forma, "
strSQL = strSQL & " InmAlquilerItem.Artículo AS Artículo, "
strSQL = strSQL & " InmAlquilerItem.Denominación AS Descripción, "
strSQL = strSQL & " InmAlquilerItem.NSerie AS NSerie, "
strSQL = strSQL & " InmAlquiler.Comienzo AS Comienzo, "
strSQL = strSQL & " InmAlquiler.Fin AS Fin, "
strSQL = strSQL & " InmAlquiler.Ubicación AS Ubicación, "
strSQL = strSQL & " InmAlquilerItem.Importe AS Importe "
strSQL = strSQL & " FROM "
strSQL = strSQL & " (InmAlquilerItem INNER JOIN InmAlquiler ON InmAlquilerItem.Contrato = InmAlquiler.Código) "
strSQL = strSQL & " LEFT JOIN CodClientes ON InmAlquiler.Cliente = CodClientes.Código "
strSQL = strSQL & " WHERE "
strSQL = strSQL & " (NOT CodClientes.Nombre IS NULL) "
If CboMes.ListIndex = 11 Then
strSQL = strSQL & " AND InmAlquiler.Comienzo < CvDate('01/01/" & Format$(VarToNum(TxtEjercicio.Text) + 1, "0000") & "') "
Else
strSQL = strSQL & " AND InmAlquiler.Comienzo < CvDate('01/" & Format$(CboMes.ListIndex + 2, "00") & "/" & Trim$("" & TxtEjercicio.Text) & "') "
End If
strSQL = strSQL & " AND InmAlquiler.Fin > CvDate('01/" & Format$(CboMes.ListIndex + 1, "00") & "/" & Trim$("" & TxtEjercicio.Text) & "') "
If Len(Trim$("" & TxtCliente.Text)) > 0 Then
strSQL = strSQL & " AND InmAlquiler.Cliente = '" & Trim$("" & TxtCliente.Text) & "' "
End If
strSQL = strSQL & " ORDER BY "
strSQL = strSQL & " CodClientes.Nombre, "
strSQL = strSQL & " InmAlquilerItem.Artículo, "
strSQL = strSQL & " InmAlquiler.Referencia "
Set tbCursor = dbBaseDeDatos.OpenRecordset(strSQL, dbOpenForwardOnly)
En el FROM, usa INNER JOIN, LEFT JOIN....cosas que en mi vida he visto, pero según deduzco en SQL sería :
Código:
FROM InmAlquilerItem,InmAlquiler,CodClientes
WHERE CodClientes.nombre NOT NULL
AND InmAlquilerItem.contratrato=InmAlquiler.codigo
AND InmAlquiler.cliente=CodClientes.codigo
No?
Me podeis decir algún manual o algo por donde guiarme con esa sintaxis...
Es que sinó dificilmente podré modificarla y entenderla...
Gracias y un Saludo!