Where Clauses

Jan 10, 2005

I have 3 fields in my db, themeID, occasionID, and recipientID. Each field has its set of numbers. What I want is to get certain products say for recipient 3 but not occasion 3 only if theme is all but 5. How can i do that?

SELECT* FROM tblProduct WHERE RecipientID='3' AND (OccasionID <>'4' AND ThemeID <> '5') order by ItemNumber Asc

i know the code i have written above is incorrect.. i wish i know how to write if is even possible and if statement. Please help.
THanks in advance

View Replies


ADVERTISEMENT

General :: 2 Group By Clauses

Apr 17, 2013

I want to use to Group by clauses or a Group by and Order By cloause together. Below is what I am striving for. I am using a Union query with a date parameter. When I try to add the Order By Clause I get the error "You tried to execute a query that doe snot include the specified expression 'rate_type' as part of an aggregate function.

System Rate Type ....
Name 1 Fixed ....
Name 1 Variable ....
Name 2 Fixed ....
Name 2 Variable ....

[code]...

View 2 Replies View Related

Modules & VBA :: Open A Form With Multiple Where Clauses

Sep 17, 2013

I am having trouble opening a datasheet form with mulitple where clauses here the VB that I have so far

Private Sub Command192_Click()
If IsNull(Me.Startdate) = True Or IsNull(Me.Enddate) = True Or Startdate = "" Or Enddate = "" Then
MsgBox "Start AND End dates are required" '
Exit Sub '

[code]....

View 11 Replies View Related

I Hate "Where" Clauses !

Aug 27, 2004

I need some help with a Where clause in a SQL statement.

What I am trying to do is use a value that is displayed in a text box on my form as the filter criteria in a list box.

On my first form I have the user select his username from a combo box. He is then prompted for a password. Once he gets past the password form, it allows him access into the main data entry form. Once he's in, the UserID he selected from the first form is automatically displayed in a textbox known as [Text689]. This text box is set to Enabled.False so it can't be changed and it's control source is set to the table as UserID.

I have another listbox setup on the main form as a record selector. This is where it gets confusing. I can get records with no problem, what I can't figure out is how to limit the records the user can select, to what he actually has created. I want to filter his selection options based on his UserID.

I have tried everything I can think of and nothing seems to work. I think the answer lies in the where clause of my SQL statement but it continues to elude me.

example:

Select tblFTEP.[Key#],tblFTEP.UserID,tblFTEP.TraineeID, tblFTEP.DOR,tblFTEP.Date
From tbl FTEP
Where ???????? ;

What I want the where condition to say is, show only those records that match the UserID that is displayed in Text689 on the main form.

Any ideas? I am just about ready to throw this laptop out the window!

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved