write sql statement to row source
I'm trying to use an on click event in one list box to change the contents of another list box. The code I'm using re-writes the sql code to the row source property if I enclose the table names in square brackets, but doesn't generate known results. Similar SQL without the square brackets in the row source will generate the known results, won't write from the vba code.
This may be similar to what Alistair69 was trying to do.
Any help will be appreciated
Rich
Here is the code:
Using Access 2003/2000 winxp
I'm trying to use an on click event in one list box to change the contents of another list box. The code I'm using re-writes the sql code to the row source property if I enclose the table names in square brackets, but doesn't generate known results. Similar SQL without the square brackets in the row source will generate the known results, won't write from the vba code.
This may be similar to what Alistair69 was trying to do.
Any help will be appreciated
Rich
Here is the code:
Code:
Private Sub TitleList_Click()
On Error GoTo Err_TitleList_Click
Dim vSearchString, x As String
vSearchString = Me.TitleList.Column(1)
Dim abc As String
abc = "SELECT [COPY].CopyKey,"
abc = abc & "[COPY].CopyID,"
abc = abc & "[TITLE].Title,"
abc = abc & "[TITLE].Edition"
abc = abc & " FROM ([COPY] INNER JOIN ON [COPY].FK_ISBN=[TITLE].PK_ISBN WHERE ((([COPY].CopyKey)
Not In (SELECT FK_CopyKey From ISSUES_to_STUDENT Where DateIn Is NULL)))"
abc = abc & "AND (([Title].Title Like " & vSearchString & "));"Me.FK_CopyKey.RowSource = abc
Me.FK_CopyKey.Requery
Me.Refresh
Exit_TitleList_Click:
Exit Sub
Err_TitleList_Click:
MsgBox Err.Description
Resume Exit_TitleList_Click
End Sub
Using Access 2003/2000 winxp
Last edited: