SQL string not working

chobo321321

Registered User.
Local time
Yesterday, 19:00
Joined
Dec 19, 2004
Messages
53
Hi, sorry to make a new topic so soon, but I ran into some SQL problems with my form. Right now I just have a combo box that contains different genres that should only load up albums associated with the selected genre in a listbox.

I first tried creating the query in the query design view, and I got the results I was looking for, so I switched the view over to SQL view, and cut and paste the code into the afterupdate event procedure for the combo box, and removed some of excess brackets, and ran it, but it doesn't come up with any records, and it doesn't give me any error messages.

The message box in the screeshot below display the sql string I am using, and the number at the end of it changes depending on what you choose in the combo box. I also put in a screenshot of the access sql string that works the query design window.

I also have a snipplet of the relationship diag for the tables I am using in the query below.

Any help is appreciated, thanks.

query0et.gif


relationex1zk.gif
 
If GenreID is numeric, then you should use «=» instead of «LIKE» which is used for strings.
 
I did use "=" instead of like in the code builder window. The sql statement with the "like" in it is from the sql view in the access query window.
 
1. Like should only be used with strings. The AlbumID is a number.
2. When Like is used, it needs to be accompanied by one or more wildcards or it doesn't make any sense.
3. Only string variables are surrounded with quotes. The AlbumID is a number.
 

Users who are viewing this thread

Back
Top Bottom