SELECT * FROM payroll
WHERE YEAR =2004
is not what you're looking for. Could you tell us more about the table structure (column names and types that sort of thing), and how you're getting the information to search by (in a form, combo boxes, text boxes etc)?
Ryker, thanks for your response. Basically what Im trying to do (not very knowledgeable with access) is to find a record within the payroll table. This is the code that i have, my only problem is the concatination of the 3 strings my criteria will be based upon.
Dim rst As New ADODB.Recordset, strQSt as string
strQSt = "SELECT [Year],[Month], [Week] FROM tblPayroll WHERE [Year] = " & Me!txtYear & "[Month]=" & Me!txtMonth & "[Week] =" & Me!txtweek & ""
rst.Open strQSt, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
If Not rst.EOF Then
MsgBox ("Record exists"), vbInformation
Set rst = Nothing
My problem is with the using of quotes to concatinate, having a hard time trying to figure out how the syntax works when using more the one string
I works just fine if i use only the [Year] but when adding the rest, it crashes.Its the quote things im sure
It's definitely going to crash. You must have the word AND when using more than one criteria:
strQSt = "SELECT [Year],[Month], [Week] FROM tblPayroll WHERE [Year] = " & Me!txtYear & " AND [Month]=" & Me!txtMonth & "AND [Week] =" & Me!txtweek & ""
is a bit closer to what you want, but I'm still not sure it'll work. Try stepping throught he code. Use the debug window to get the value of strQST and copy it, then poste it into a query (just open a new query in SQL view), run it, and see if it gives you any errors.