Hi, I only joined yesterday. I have a problem with the following code where I get a missing operator error. Could someone please tell me what I am doing wrong.
Thanks
John

'---------------------------------------------------------------------------
' Function: strbuildSQLstr
' Purpose: Build SQL String to retrieve ADO Recordset
' Paramters: strChoice- string(Good or Bad),strStart- string(start date)
' strEnd - string( End Date)
' Returns: String - SQL Statement build with parameters passed
'---------------------------------------------------------------------------
Function strbuildSQLstr(strChoice As String) As String
Dim strtemp As String

strtemp = "Select * from SizeRange Where Style =" & "'" & txtStyle & "'"
If strChoice > "" Then strtemp = strtemp & "'" & " and WHERE type =" & "'" & strChoice & "'"

' return the SQL String
strbuildSQLstr = strtemp & " " & "ORDER by Date"

please change the order by field name. Date is not a recomended field name in database as it is a predefined data type.

Hi,

Once already Where is given in the first statement, after that use only "And"

Change the second line to :

If Trim(strChoice) <> "" Then 
    strtemp = strtemp & " and type ='" & strChoice & "' "
End If

Regards
Veena

Thanks for your help. Is it the fact I am using 'Date' as a field name or actually ordering by date that is a problem?

Think it is working now anayway.
John

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.