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

SQL Where statement giving errors

Status
Not open for further replies.

rperre

Programmer
Jan 25, 2005
39
US
hey, I want to open a recordset and use the WHERE part to filter the records I need!
When I call the Openrecordset it gives me a error saying:
"too few parameters, expecting 3"

What is this for, I tried putting all the fields separately in the SQL statement in stead of * and all kinds of other things, but nothing seems to work. What am I doing wrong here?????

Code:
    strSQL = "SELECT * FROM [Financial summary] WHERE ((([Prop ID])=build) AND (([Term month])=tm) AND (([Term year])=ty))"
    Set fin = db.OpenRecordset(strSQL)

build, tm and ty are given in calling the sub and are numbers (long int)

Also, somehow I can't use DAO.recordset but have to use Object when declaring the recordsets. DAO is installed and the dim as Dao.recordset works, but I can't do anything with these recordsets

thanks,

Richard
 
Never mind about the SQL WHERE statement, I took the values out of the string "" and it works (ofcourse!!)

But still, calling the following statement somehow does not give me the same options for recordsets

Dim inc as DAO.Recordset

I have to use:

Dim inc as Object

What's wrong with this???

Richard
 
I suppose you have somewhere a line like this:
Set db = CurrentDB
So, you have to use this declaration:
Dim fin As DAO.Recordset

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I do have that line, although you don't have to use that! You can use Currentdb directly in the statement!

Dim fin As DAO.Recordset

this works but somehow it doesn't give me the same options in calling variables. If I do:

Dim fin as Object

I can use fin.[building ID] to fill, edit or use the data, but if I use the first Dim (with the DAO.Recordset) I can't use this same line and fin![building ID] doesn't work either. It's a big ? to me!
The error is: "Method or data member not found"

Thanks for the reply though,

Richard
 
hmm, every time I ask a question, I find the answer myself, LOL

It works now, I had different instances around the code and it gave me errors on different one's every time.

Thanks for the help,

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top