Sarah-
What are you trying to do with the recordset in code? If you're going to open it and navigate through it in code, just use SQL. If you want the result exposed in the User Interface, then you'll have to create a QueryDef object and set its SQL property.
John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
(Paris, France)
On Mar 26, 2015, at 4:50 PM, sarahk@schemesoftware.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
Now I understand, the query is a SELECT query.
Follow up question:
Is it better to create the query in the VBA code or is it better to create the query in query design and save it and then call it from the vba code.
What is the better method or it makes no difference?.
Sarah-
If your query is a SELECT query, then you cannot use Execute. What is the SQL of your query?
John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
(Paris, France)
On Mar 25, 2015, at 9:43 PM, sarahk@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:I recall that it is better to use db.excute for a query than docmd.openquery.
I am struggling with the following, the same query works when I run it with DOcmd, but does not work with db.execute:
DoCmd.OpenQuery "mltc1bp2", , acEdit (THIS WOKRS)
CurrentDb.Execute "mltc1bp2" (THIS DOES NOT WORK)
also tried
set DB=currentdb()
DB.execute and it does not work either.
However I have other queries that work fine with db.execute,.
What might be the reason?.
Sarah
__._,_.___
Posted by: John Viescas <johnv@msn.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (5) |
.
__,_._,___
Tidak ada komentar:
Posting Komentar