A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Compile Error : Type Mismatch



 
 
Thread Tools Display Modes
  #1  
Old April 21st, 2010, 06:18 PM posted to microsoft.public.access
WildlyHarry
external usenet poster
 
Posts: 112
Default Compile Error : Type Mismatch

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 ...

  #2  
Old April 21st, 2010, 06:45 PM posted to microsoft.public.access
ghetto_banjo
external usenet poster
 
Posts: 325
Default Compile Error : Type Mismatch

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
  #3  
Old April 22nd, 2010, 02:19 AM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Compile Error : Type Mismatch

On Wed, 21 Apr 2010 10:18:01 -0700, WildlyHarry
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]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:59 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.