WHERE Statement Help Please

crisb184

Registered User.
Local time
Today, 06:24
Joined
Aug 30, 2013
Messages
29
Hello,

I have an AfterUpdate event where I want a list box to be populated based on three different criteria based on a table in my database
1. Complete = False AND
2. Supplier on form = supplier in table AND
3. Status in table = "SUPPLIER_RFQ FOLLOW-UP" OR "SUPPLIER_RE-RFQ TO OTHER SUPPLIER"

I am having trouble with the last OR statement criteria, i cannot get this to return values correctly. Here is my code:

Code:
Me.cboSupplier.RowSource = "SELECT DISTINCT [Consolidated_Master_Req_Pool].[RFQ Contact] " & _
                            "FROM Consolidated_Master_Req_Pool " & _
                            "WHERE consolidated_master_req_pool.Complete = FALSE AND [Consolidated_Master_Req_Pool].[RFQ Supplier] = '" & Nz(Me.cboStatusRFQ) & "' And [consolidated_master_req_pool.Status] = '" & "SUPPLIER_RFQ FOLLOW-UP" & "' OR [consolidated_master_req_pool.Status] = '" & "SUPPLIER_RE-RFQ OTHER SUPPLIER" & "'" & _
                            "ORDER BY [Consolidated_Master_Req_Pool].[RFQ Contact];"

I know that I am probably goofing on my or statement, so any help from someone who knows what they are soing (unlike me) is greatly appreciated.

Thanks,
Cris
 
I think that you need to wrap the last this or that in brackets
I'm not confident of getting the syntax correct on the fly but it should read

Where criteria1 and criteria2 and ( criteria3 or criteria4)

Brian
 
Thanks Brian, that appears to have done the trick. My new code is:

Code:
Private Sub cboStatusRFQ_AfterUpdate()
 Me.cboSupplier.RowSource = "SELECT DISTINCT [Consolidated_Master_Req_Pool].[RFQ Contact] " & _
                            "FROM Consolidated_Master_Req_Pool " & _
                            "WHERE consolidated_master_req_pool.Complete = FALSE AND [Consolidated_Master_Req_Pool].[RFQ Supplier] = '" & Nz(Me.cboStatusRFQ) & "' And [COLOR=red]([/COLOR][consolidated_master_req_pool.Status] = '" & "SUPPLIER_RFQ FOLLOW-UP" & "' OR [consolidated_master_req_pool.Status] = '" & "SUPPLIER_RE-RFQ TO OTHER SUPPLIER" & "'[COLOR=red])[/COLOR]" & _
                            "ORDER BY [Consolidated_Master_Req_Pool].[RFQ Contact];"
 

Users who are viewing this thread

Back
Top Bottom