I'm converting an application from Jet to SQL Server using Access 2002. My legacy code frequently uses:
Dim db As DAO.Database
Set db = CurrentDb
I because getting errors on the 'Set' statement even though I had a reference set to the DAO 3.6 Object Library so I started to convert the code to use ADO and the 'Find' method of the ADO recordset is different from the 'FindFirst' of the DAO recordset. Using a criteria statement without an 'And' works but the second I make the criteria complex (two separate data elements combined with and) the code fails saying "Error 3001, Arguments are of the wrong type or out of the acceptable range." I have used debug to verify the values of the combo box columns are correct and the criteria is correctly forms so obviously there is something I don't know about building the criteria. None of the 8 books I have cover the 'Find' method is sufficiently to clear up my questions and the help is rather unhelpful.
Set rst = Me.RecordsetClone
rst.MoveFirst
strCriteria = "[PN]=""" & Me.cboQFind.Column(0) & """ And [Cage]=""" & Me.cboQFind.Column(1) & """;"
=> rst.Find strCriteria, 1, adSearchForward
Any assistance would be greatly appreciated.
-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
Dim db As DAO.Database
Set db = CurrentDb
I because getting errors on the 'Set' statement even though I had a reference set to the DAO 3.6 Object Library so I started to convert the code to use ADO and the 'Find' method of the ADO recordset is different from the 'FindFirst' of the DAO recordset. Using a criteria statement without an 'And' works but the second I make the criteria complex (two separate data elements combined with and) the code fails saying "Error 3001, Arguments are of the wrong type or out of the acceptable range." I have used debug to verify the values of the combo box columns are correct and the criteria is correctly forms so obviously there is something I don't know about building the criteria. None of the 8 books I have cover the 'Find' method is sufficiently to clear up my questions and the help is rather unhelpful.
Set rst = Me.RecordsetClone
rst.MoveFirst
strCriteria = "[PN]=""" & Me.cboQFind.Column(0) & """ And [Cage]=""" & Me.cboQFind.Column(1) & """;"
=> rst.Find strCriteria, 1, adSearchForward
Any assistance would be greatly appreciated.
-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------