Link to home
Start Free TrialLog in
Avatar of Laurence Martin
Laurence MartinFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Defining a Query in code

I am trying to compile my mdb in Access 2010 and this line of code is throwing up an error:

Set db.QueryDefs("qry13bCreditStatus").SQL = stSQL

The error is "Invalid use of property"

Previously in the same procedure:

set db=opendatabase(stdatapath)

If you can see what I'm doing wrong that would be great.
Avatar of Andy Marshall
Andy Marshall
Flag of United Kingdom of Great Britain and Northern Ireland image

The Set is causing the problem, I think.  Try something like:

Dim qdf As DAO.QueryDef
Set qdf = CurrentDb.QueryDefs("qry13bCreditStatus")
qdf.SQL = "SELECT Category FROM Categories"
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think my answer would have worked too!!  Oh well.

Yes, it would have.  For the record, I would not object to a split :)