Prev: MS says that all tables should live in SQL (for performance reasons)
Next: Reports created in Access 2003
From: WildlyHarry on 21 Apr 2010 13:18 I am trying to use data entered on a form to create an SQL string that will be passed to a query. Every time I compile the VBA I get the "Compile Error: Type Mismatch" on the set qdf = query name line. I have checked my reference library and my DAO 3.6 is the highest priority. Below is my code. Any idea what the issue might be? Private Sub Command172_Click() Dim db As DAO.Database Dim qdf As DAO.QueryDef Set db = CurrentDb() Set qdf = "qry short list status report" qdf = "SELECT ...
From: ghetto_banjo on 21 Apr 2010 13:45 not sure with DAO, but when i do other query defs, i need to reference the database in the SET qdf. Set qdf = db.QueryDefs("qry short list status report") again, not sure when using DAO, but I imagine it something like that
From: John W. Vinson on 21 Apr 2010 21:19
On Wed, 21 Apr 2010 10:18:01 -0700, WildlyHarry <WildlyHarry(a)discussions.microsoft.com> wrote: >I am trying to use data entered on a form to create an SQL string that will >be passed to a query. Every time I compile the VBA I get the "Compile Error: >Type Mismatch" on the set qdf = query name line. I have checked my reference >library and my DAO 3.6 is the highest priority. Below is my code. Any idea >what the issue might be? > >Private Sub Command172_Click() > >Dim db As DAO.Database >Dim qdf As DAO.QueryDef >Set db = CurrentDb() >Set qdf = "qry short list status report" > >qdf = "SELECT ... Try: Set qdf = db.Querydefs("qry short list status report") Set qdf.SQL = "SELECT... Or more simply, Set qdf = db.CreateQuerydef("SomeName", "SELECT...") and then use SomeName in your further processiong. -- John W. Vinson [MVP] |