Execute Query Function in VB

DeutchBose

Board Regular
Joined
Mar 22, 2004
Messages
83
I have an access query that I'm trying to run through vba code...I'm doing the following:

Dim qdProcess As QueryDef

Dim dbProcess As Database

Set dbProcess = CurrentDb()

Set qdProcess = dbProcess.QueryDefs("aqryLIMAdeals_MMConc")
qdProcess.Execute

"aqryLIMAdeals_MMConc" is an append query that works just fine when I run it in Access...but the code gets hung up with 'qdProcess.Execute'

I get the following error:

'Too few paramaters. Expected 1'
I'm not sure what parameters I would need?

Any ideas?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Try
DoCmd.OpenQuery "aqryLIMAdeals_MMConc"

instead. You may want to look at

DoCmd.SetWarnings True / False

as well.

HTH

Peter
 
Upvote 0
I know that'll work, however I need to then use the 'RecordsAffected' function which will only work if using the 'Execute' function beforehand.

I realise I could find the Records Affected some other way, but it's just so strange...the whole thing was working just fine in Access 97 on NT, but converting it to Access XP on Windows XP, this has become a problem all of a sudden.
 
Upvote 0
I am not sure if this will help as it is code for 97 but it is an addaption of how I force parameter queries to update themselves in code.

Code:
Dim qdProcess As QueryDef
Dim dbProcess As Database
Dim prm As Parameter

Set dbProcess = CurrentDb()
Set qdProcess = dbProcess.QueryDefs("aqryLIMAdeals_MMConc")
For Each prm In qdProcess.Parameters
   prm.Value = Eval(prm.Name)
Next prm
qdProcess.Execute

Peter
 
Upvote 0

Forum statistics

Threads
1,221,783
Messages
6,161,938
Members
451,730
Latest member
BudgetGirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top