0
votes

I have a really annoying issue that I'm having which has worked perfectly well historically in other Access dbs.

I have, as a test, a form with a button. The click event button is to run a simple query, this is the VBA:

Private Sub Command0_Click()

DoCmd.SetWarnings False

DoCmd.OpenQuery "mktbl_qry_Useable_Leads", acViewNormal, acEdit

DoCmd.SetWarnings True

End Sub

Very simple and straight forward, however, I constantly get the Macros pop up list asking me to select a sub routine.

Is there a reason for this? I have tried other queries with the same result and also another blank form with the same issue. Its driving me insane.

Help is much appreciated.

1
Running query should not show macro dialog. Looks like your database damaged. Try to create new accdb and copy all objects from current database to new one first. - Sergey S.
@Fionnuala What warnings could/would the above example hide, that a db.Execute would not? Apologies to the OP for the sidebar. Btw, have you tried a compact & repair? - GavinP
Thank you all. It was me being silly and forgetting that in Access you cannot run code on a form/form button in debug while calling a sub routing in another module. Its been a while since I last built an access db. It runs fine when run within form view. - TSQL_Newbie

1 Answers

0
votes

You can use the Database object to run query's. For a simple query you don't need to create a query in the database window

CurrentDB.Execute "qdRunUpdateQuery", dbFailOnError + dbSeeChanges

or

CurrentDB.Execute "Update article set price = 10 where id=23", dbFailOnError + dbSeeChanges