Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare Combo Box In SQL

Status
Not open for further replies.

RAxel

MIS
Sep 8, 2005
121
US
I have a form where the user can select the Year for something and I want that Year to be used in a SQL statement. Like so:

Code:
strSQL = strSQL + " WHERE ((" & tblEmployees & ".EmployeeID = " & tblQuarterlyInformation & ".EmployeeID)" & _
                              " AND (" & tblQuarterlyInformation & ".Year = " & cboYear.Value & "))"

The combo box (cboYear) is 'Unbound', I've manually entered the values. There is only one column of values, example: 03/04, 04/05, 05/06, etc..

The SQL statement works if I take out the 'AND' part but if I put it in, then I get no returned records. I've tried cboYear.Column(1) and Column(0). I've even hardcoded the year at the end of the statement to look like:
Code:
strSQL = strSQL + " WHERE ((" & tblEmployees & ".EmployeeID = " & tblQuarterlyInformation & ".EmployeeID)" & _
                              " AND (" & tblQuarterlyInformation & ".Year = 03/04))"
with no records returned.

And yes, I have checked to make sure there is data meeting the criteria. :)
 
Please disregard, I forgot the stupid apostrophies around the combo box value. Ah, the little things...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top