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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Required Error

Status
Not open for further replies.

pingit

MIS
Nov 24, 2003
37
NZ
Hello

I am trying to query a database using two dates and keep getting an "Object Required" error with no number. I get two dates from text boxes, format them and convert to srtings and use in an SQL select statement. Any help is much appreciated

eDate = CStr(Format(Forms![PaymentSchedule]![Text10], "mm/dd/yyyy"))
sDate = CStr(Format(Forms![PaymentSchedule]![Text8], "mm/dd/yyyy"))

strSQL1 = "SELECT DISTINCT Assessment.StaffID, Staff.Lname, Staff.Fname, Assessment.datePaid "
strSQL1 = strSQL1 + "FROM Staff INNER JOIN Assessment ON Staff.StaffID = Assessment.StaffID "
strSQL1 = strSQL1 + "WHERE (Assessment.datePaid > #" & sDate & "#"
strSQL1 = strSQL1 + " And Assessment.datePaid < #" & eDate & "#);"

rst.Open strSQL1, CurrentProject.Connection, adOpenKeyset, adLockOptimistic

thanks in advance
 
Which line is highlighted when in debug mode ?
Where is rst instantiated ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Stepping through the code after the hits
rst.Open strSQL1, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
it jumps to the err_ and the "Object Required"

thanks
 
Hello PHV

Thanks for your reply. Your question "Where is rst instantiated ?" made me revisit my code and I found the error I declared rst1 and rst2 not rst

Thanks for your reply problem solved

 
Tip: use the Option Explicit instruction ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top