
Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
On May 24, 12:19 pm, "Dirk Goldgar" <d...@NOdataSPAMgnostics.com>
wrote:
> It sounds like the rowsource string you're assigning to the list box
> isn't formed correctly, so that the text value from the combo box is
[quoted text clipped - 5 lines]
>
> (please reply to the newsgroup)
Private Sub Heading_KeyUp(KeyCode As Integer, Shift As Integer)
Dim strText As String
With Me!Heading
strText = Left(.Text, .SelStart)
End With
Me!Name.RowSource = "SELECT DISTINCT Reports.Heading, Reports.
[Report Name] FROM Reports WHERE (((Reports.Heading) Like " & Chr(34)
& "*" & Chr(34) & " & " & strText & " & " & Chr(34) & "*" & Chr(34) &
"));"
Me!Name.Requery
End Sub
Dirk Goldgar - 24 May 2007 20:56 GMT
> On May 24, 12:19 pm, "Dirk Goldgar" <d...@NOdataSPAMgnostics.com>
> wrote:
[quoted text clipped - 16 lines]
> Me!Name.Requery
> End Sub
Apparently you modified the statement with the intention of searching
for the text anywhere in the Heading field, rather than just at the
start of the field, but you made a small mistake and ended up with
strText outside the embedded quotes. I don't know if you need to search
anywhere in the field, since your combo box is always going to be
choosing from the start of the field, but if that's what you want to do,
I think this will work better:
Me!Name.RowSource = _
"SELECT DISTINCT " & _
"Reports.Heading, Reports.[Report Name] " & _
"FROM Reports " & _
"WHERE Reports.Heading Like " & _
Chr(34) & "*" & strText & "*" & Chr(34)
In addition to fixing the quoting, I removed the extra parentheses and
the terminal semicolon. They did no harm, but you don't really need
them.
Also, delete the requery line:
> Me!Name.Requery
Changing the RowSource property forces a requery, so requerying it a
second time serves no purpose.

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)