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  

Query Def not recognized



 
 
Thread Tools Display Modes
  #1  
Old April 28th, 2010, 01:15 PM posted to microsoft.public.access
alex
external usenet poster
 
Posts: 581
Default Query Def not recognized

Query Def not recognized

Hello,
Using Access ’03…

I’ve created a qdf in VBA and I’d like to use it as part of another
query…

My problem, is that the qdf is not being recognized; i.e., when the
query runs, I get a parameter box asking for a value?

Here’s some of my code:
‘’’’’’’’’’’’’’’’
Set dbs = CurrentDb
Dim strQDFname As String
strQDFname = "myQryDef" 'query def name

With dbs
Set qdf = .CreateQueryDef(strQDFname, strQDFsql)
qdf.Close
End With
Set qdf = Nothing

‘sql code using qdf
Dim strSQL As String
strSQL = _
" myQryDef.Field1, " & _
" myQryDef. Field2, " & _
" myQryDef. Field3, " & _
" myQryDef. Field4, " & _
" myTable.Field1, " & _
" myTable. Field2, " & _
" myTable. Field3, " & _
" myTable. Field4 "
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
I can see the query object (myQryDef) and I can use it with other
query objects (I can even run it by just clicking on it); I just can’t
use it w/ VBA for some reason? Do I need to append it to some
collection?

Any thoughts?
alex





  #2  
Old April 28th, 2010, 01:48 PM posted to microsoft.public.access
Roger Carlson
external usenet poster
 
Posts: 824
Default Query Def not recognized

Unless you're leaving a bunch out, this:
‘sql code using qdf
Dim strSQL As String
strSQL = _
" myQryDef.Field1, " & _
" myQryDef. Field2, " & _
" myQryDef. Field3, " & _
" myQryDef. Field4, " & _
" myTable.Field1, " & _
" myTable. Field2, " & _
" myTable. Field3, " & _
" myTable. Field4 "

is not a complete SQL statement. Until you put "myQryDef" in a From clause
(which doesn't appear to exist) it won't "recognize" the query.

If this is not the full code, please post it.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/...UBED1=ACCESS-L


"alex" wrote in message
...
Query Def not recognized

Hello,
Using Access ’03…

I’ve created a qdf in VBA and I’d like to use it as part of another
query…

My problem, is that the qdf is not being recognized; i.e., when the
query runs, I get a parameter box asking for a value?

Here’s some of my code:
‘’’’’’’’’’’’’’’’
Set dbs = CurrentDb
Dim strQDFname As String
strQDFname = "myQryDef" 'query def name

With dbs
Set qdf = .CreateQueryDef(strQDFname, strQDFsql)
qdf.Close
End With
Set qdf = Nothing

‘sql code using qdf
Dim strSQL As String
strSQL = _
" myQryDef.Field1, " & _
" myQryDef. Field2, " & _
" myQryDef. Field3, " & _
" myQryDef. Field4, " & _
" myTable.Field1, " & _
" myTable. Field2, " & _
" myTable. Field3, " & _
" myTable. Field4 "
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
I can see the query object (myQryDef) and I can use it with other
query objects (I can even run it by just clicking on it); I just can’t
use it w/ VBA for some reason? Do I need to append it to some
collection?

Any thoughts?
alex






  #3  
Old April 28th, 2010, 02:23 PM posted to microsoft.public.access
alex
external usenet poster
 
Posts: 581
Default Query Def not recognized

On Apr 28, 8:48*am, "Roger Carlson"
wrote:
Unless you're leaving a bunch out, this:
‘sql code using qdf
Dim strSQL As String
* * strSQL = _
* * " myQryDef.Field1, " & _
* * " myQryDef. Field2, " & _
* * " myQryDef. Field3, " & _
* * " myQryDef. Field4, " & _
* * " myTable.Field1, " & _
* * " myTable. Field2, " & _
* * " myTable. Field3, " & _
* * " myTable. Field4 "

is not a complete SQL statement. * Until you put "myQryDef" in a From clause
(which doesn't appear to exist) it won't "recognize" the query.

If this is not the full code, please post it.

--
--Roger Carlson
* MS Access MVP
* Access Database Samples:www.rogersaccesslibrary.com
* Want answers to your Access questions in your Email?
* Free subscription:
*http://peach.ease.lsoft.com/scripts/...UBED1=ACCESS-L

"alex" wrote in message

...
Query Def not recognized

Hello,
Using Access ’03…

I’ve created a qdf in VBA and I’d like to use it as part of another
query…

My problem, is that the qdf is not being recognized; i.e., when the
query runs, I get a parameter box asking for a value?

Here’s some of my code:
‘’’’’’’’’’’’’’’’
Set dbs = CurrentDb
* * Dim strQDFname As String
* * strQDFname = "myQryDef" 'query def name

* * With dbs
* * * * Set qdf = .CreateQueryDef(strQDFname, strQDFsql)
* * * * qdf.Close
* * End With
* * Set qdf = Nothing

‘sql code using qdf
Dim strSQL As String
* * strSQL = _
* * " myQryDef.Field1, " & _
* * " myQryDef. Field2, " & _
* * " myQryDef. Field3, " & _
* * " myQryDef. Field4, " & _
* * " myTable.Field1, " & _
* * " myTable. Field2, " & _
* * " myTable. Field3, " & _
* * " myTable. Field4 "
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
I can see the query object (myQryDef) and I can use it with other
query objects (I can even run it by just clicking on it); I just can’t
use it w/ VBA for some reason? *Do I need to append it to some
collection?

Any thoughts?
alex


That was it Roger!
I forgot to change the name of the query in the FROM clause.
Thanks for pointing me in the right direction.
alex
 




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 06:25 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.