Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Execute Query Question

Posted on 1999-07-20
3
Medium Priority
?
162 Views
Last Modified: 2012-05-04
Set myworkspace = DBEngine(0)
Set mydatabase = myworkspace.OpenDatabase(glocationofdb)
Set myquerydef = mydatabase.QueryDefs("qryCreateTableForCrystal")  ' Open existing QueryDef.
myquerydef.Parameters(0) = Data1.Recordset.Fields(0).Value
'
'the next line while it runs the Creat Table Query, it returns an error
'  3001         Invalid argument
'
myquerydef.Execute myquerydef

what am I doing wrong?
0
Comment
Question by:eeevbeee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
smegghead earned 400 total points
ID: 1526243
If 'myquerydef' is of type querydef, the only parameter you can include following the execute method is 'options'

for example:
myquerydef.execute dbFAILONERROR

whereas, if you are applying the execute method to either a database or a connection (not a querydef), then the first parameter is the source (SQL string or querydef) and the second is the options...

hope this helps.
0
 
LVL 10

Expert Comment

by:smegghead
ID: 1526244
Also, I'm not sure what you're doing with workspaces. If you typed the code manually and made a few typos, I appologise for being pedantic.

You should use the syntax... (assuming you want to use the default workgroup)

set myworkspace=dbengine.workspaces(0)

dbengine is just an object, not a collection.

I know this is probably irrelevant to your question, but I just thought I'd say !!
0
 

Author Comment

by:eeevbeee
ID: 1526245
thanks. I certainly had the wrong syntaxt. now it's working.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question