By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,491 Members | 879 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,491 IT Pros & Developers. It's quick & easy.

Query opens in Datasheet view when run from VBA

100+
P: 294
Is there a way to 'stifle' a query opening up in datasheet view when it is being ran? I am calling the queries like this:

Expand|Select|Wrap|Line Numbers
  1.                 DoCmd.RunCommand acCmdSaveRecord
  2.                 DoCmd.SetWarnings False
  3.                 DoCmd.OpenQuery "DeathVestingDateUpdateQry"
  4.                 DoCmd.OpenQuery "BeneficiaryAwardsQry"
  5.                 DoCmd.OpenQuery "BeneficiaryAwardsUpdateQry"
  6.                 DoCmd.OpenQuery "BenePayoutAwardSumQry"
  7.                 DoCmd.OpenQuery "BenePayoutUnitsCorrectQry"
  8.                 DoCmd.OpenQuery "BenePayoutNAVUpdateQry"
  9.                 DoCmd.OpenQuery "BeneficiaryPytUpdateQry"
  10.                 DoCmd.OpenQuery "BeneEmployeePytDelQry"
  11.                 DoCmd.SetWarnings True
  12.  
  13.                 Forms("AstProfileFrm").SetFocus
  14.                 DoCmd.Minimize
  15.  
  16.         DoCmd.OpenReport "BeneficiaryAPRpt", acViewPreview
None of the queries do this except for "BenePayoutAwardSumQry".

I suppose it would be something with View or Design Mode but I'm just not sure.

Note: I tried the db.Execute method instead of DoCmd.OpenQuery and I kept getting errors. This method works fine for my purposes, aside from this happening.

Any help would be appreciated! Thanks
Feb 26 '14 #1

✓ answered by Rabbit

Are the other queries action queries while BenePayoutAwardSumQry is a select query?

There's no point in running a select query if you don't want to see the results. And if it's an action query, then it wouldn't display the results, it would just take the action.

Share this Question
Share on Google+
7 Replies


ADezii
Expert 5K+
P: 8,597
The 2nd Argument of the OpenQuery() Method is the View Mode which can be one of seven possible Constants.
Feb 26 '14 #2

100+
P: 294
Correct, ADezzi. I'm with you. Do you know why it is showing the query? I don't want the user to see the query results in datasheet at all. In fact, it should all occur behind the scenes.
Feb 26 '14 #3

Rabbit
Expert Mod 10K+
P: 12,315
Are the other queries action queries while BenePayoutAwardSumQry is a select query?

There's no point in running a select query if you don't want to see the results. And if it's an action query, then it wouldn't display the results, it would just take the action.
Feb 26 '14 #4

100+
P: 294
Very true - not sure why I thought it was necessary. I think because I used it's results in another query I though I would need it, however that is not the case. Thanks!
Feb 26 '14 #5

Rabbit
Expert Mod 10K+
P: 12,315
No problem. And for future reference, you don't need to "pre-run" select queries that are referenced elsewhere. The query results will be returned when referenced without having the query open.
Feb 26 '14 #6

NeoPa
Expert Mod 15k+
P: 31,186
Rabbit's nailed it Mark (I've done the honours for you).

That's also why the .Execute() failed. It can only work with action queries.
Mar 1 '14 #7

100+
P: 294
Appreciate it, Rabbit and NeoPa, per usual! There are a lot of little nuances that I am still not aware of, but am learning ;P
Mar 2 '14 #8

Post your reply

Sign in to post your reply or Sign up for a free account.