Hello, I'm trying to change the row source of a listbox using VBA. My listbox is set to show column heads and multi select is set to none. I copied my sql( actually two of them, one for each of the info I want to show) from a query that returns the proper info but when I set the row source in vba and requery the listbox the listbox is empty. I tried hard coded the sql in the listbox's row source(with the proper syntax changes) and it works fine. here's my two sql"s
Any ideas on why I can't get this to show in the listbox?
Thanks, Jim
Code:
Private Sub chkOpenReferrals_Click()
Debug.Print
Dim strSQL As String
If Me.chkOpenReferrals = -1 Then
strSQL = "SELECT tblHistory.TicketNum, tblHistory.StartDate, tblHistory.TermDate, tblContractor.ContractorName, tblHistory.ReferralNumber, tblHistory.ReferralComplete" & _
"FROM tblContractor INNER JOIN tblHistory ON tblContractor.[ContrID-PK] = tblHistory.ContrID" & _
" WHERE (((tblHistory.TicketNum)=[forms]![frmMain].[cboticketnum]) AND ((tblHistory.ReferralComplete)=False));"
ElseIf Me.chkOpenReferrals = 0 Then
strSQL = "SELECT tblHistory.TicketNum, tblHistory.StartDate, tblHistory.TermDate, tblContractor.ContractorName, tblHistory.ReferralNumber, tblHistory.ReferralComplete" & _
"FROM tblContractor INNER JOIN tblHistory ON tblContractor.[ContrID-PK] = tblHistory.ContrID" & _
" WHERE (((tblHistory.TicketNum)=[forms]![frmMain].[cboticketnum]));"
End If
Me.lstReferrals.RowSource = strSQL
Me.lstReferrals.Requery
End Sub
Thanks, Jim