pokeymonsc
Technical User
I have an access 2002 front end with an ODBC connection to a SQL server back end. I am trying to open my form using the following code:
Dim rs As DAO.Recordset
Dim QDef As QueryDef
Dim tmpID As Integer
If Not IsNull(Int(Me.EmpID.Value)) Then
tmpID = Me.txtEmpID.Value
Set QDef = CurrentDb.CreateQueryDef("", "select empid from dbo_payperiodcharges where empid = " & tmpID & " and payperiod between '10/01/2004' and '9/30/2005'")
Set rs = QDef.OpenRecordset
counter = rs.RecordCount
End If
I am having trouble with the dates between Access and T-SQL. In the above code I get a 'Type Mismatch' at the line "Set rs = QDef.OpenRecordset". If I use # to bracket the dates I get a 'Syntax Error'.
What I'm trying to do is to limit multiyear records to a single year. Hardcoding the dates is just the first step to setting up a parameter form, but I have to get the hardcoded dates to work first
Dim rs As DAO.Recordset
Dim QDef As QueryDef
Dim tmpID As Integer
If Not IsNull(Int(Me.EmpID.Value)) Then
tmpID = Me.txtEmpID.Value
Set QDef = CurrentDb.CreateQueryDef("", "select empid from dbo_payperiodcharges where empid = " & tmpID & " and payperiod between '10/01/2004' and '9/30/2005'")
Set rs = QDef.OpenRecordset
counter = rs.RecordCount
End If
I am having trouble with the dates between Access and T-SQL. In the above code I get a 'Type Mismatch' at the line "Set rs = QDef.OpenRecordset". If I use # to bracket the dates I get a 'Syntax Error'.
What I'm trying to do is to limit multiyear records to a single year. Hardcoding the dates is just the first step to setting up a parameter form, but I have to get the hardcoded dates to work first