I have been googling this for a while now, to no avail.
I am using a combobox in my form with this syntax to show customers who have placed orders:
I then want a listbox to show the orders on the Ordini table that have IDCliente as their foreign key, so I put this code in the afterupdate event of said cbobox:
I tested the query separately and it works as intended: I think I am failing something in the vb syntax that's supposed to pass the value to the SQL. Any thoughts?
I am using a combobox in my form with this syntax to show customers who have placed orders:
Code:
SELECT DISTINCT Ordini.IDCliente, Clienti.CognomeContatto, Clienti.NomeContatto FROM Ordini, Clienti WHERE Ordini.IDCliente = Clienti.IDCliente ORDER BY Clienti.CognomeContatto;
I then want a listbox to show the orders on the Ordini table that have IDCliente as their foreign key, so I put this code in the afterupdate event of said cbobox:
Code:
Private Sub cboOrdiniCliente_AfterUpdate()
txtDataInserimento = ""
txtDataConsegna = ""
lstOrdiniPerCliente.Visible = True
With Me![lstOrdiniPerCliente]
If IsNull(Me!cboOrdiniCliente) Then
.RowSource = ""
Else
.RowSource = "SELECT Ordini.IDOrdine, Ordini.DataOrdine, Ordini.DataConsegna " & _
"FROM Ordini" & _
"WHERE Ordini.IDCliente=" & Me.cboOrdiniCliente.Column(0)
End If
Call .Requery
End With
End Sub
I tested the query separately and it works as intended: I think I am failing something in the vb syntax that's supposed to pass the value to the SQL. Any thoughts?