Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Where problem 1

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
GB
I am trying to fill a list L5 with a distinct field Shots, but not wanting to get any NULL values.

Can someone please see my error, as it produces no data. Thanks

Me.L5.RowSource = "SELECT DISTINCT TXCLIPS.Shot" _
& " FROM (TXMASTERS INNER JOIN TXCLIPS ON TXMASTERS.ID1=TXCLIPS.ID1)" _
& " INNER JOIN KEYWORDS ON TXCLIPS.Comments Like '*' & KEYWORDS.Keyword & ' *' " _
& "WHERE (((TXMASTERS.SportorSports) Like [FORMS]![NewQuerysForm].[LNAME].[CAPTION]))" _
& "AND (((TXCLIPS.Shot)>""))" _
 
I added a space where one was missing, took out the reference to the caption and removed a bunch of ()s from the where clause. Are you sure you want to use the Caption property? Is [LNAME] a label control? Also, your last "Like" doesn't use any wild cards.

Code:
Me.L5.RowSource = "SELECT DISTINCT TXCLIPS.Shot" _
& " FROM (TXMASTERS INNER JOIN TXCLIPS ON TXMASTERS.ID1=TXCLIPS.ID1)" _
& " INNER JOIN KEYWORDS ON TXCLIPS.Comments Like '*' & KEYWORDS.Keyword & ' *' " _
& "WHERE TXMASTERS.SportorSports Like """ & [FORMS]![NewQuerysForm].[LNAME].[CAPTION] _
& """ AND TXCLIPS.Shot>''"

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks Duane.

This should be an equal to and not a like, but it seems to work okay.

"WHERE (((TXMASTERS.SportorSports) Like [FORMS]![NewQuerysForm].[LNAME].[CAPTION]))" _

I changed your -

& """ AND TXCLIPS.Shot>''"

to -

& "AND TXCLIPS.Shot>''"

and it works. So thanks for your help. Regards


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top