SQL Statement

IanT

Registered User.
Local time
Today, 11:11
Joined
Nov 30, 2001
Messages
191
Hi

I have this sql statement in some code but it appears not to work. Can any advise if it is incorrect.

strSelect = "SELECT ProductDescription, PricePerUnit FROM qryQuote " _
& "WHERE ClientID = """ & Me.cboCustomer.Column(1) & """ AND " _
& "ComparisonDate = " & strDate


Variable values:
Me.cboCustomer.Column(1) = 12
strDate = 12/06/2005 14:22:01
 
If strDate is a date then you should not prefix it with str - that's for strings. dte may be more appropriate.

Anyway, since it's a date you are dealing with you need to use the date delimiters - the # mark.

Code:
strSelect = "SELECT ProductDescription, PricePerUnit FROM qryQuote " & _
                "WHERE ClientID = """ & Me.cboCustomer.Column(1) & """ AND " & _
                "ComparisonDate = #" & strDate & "#"
 

Users who are viewing this thread

Back
Top Bottom