Keypress problem

rcollman

New member
Local time
Today, 22:23
Joined
Mar 15, 2001
Messages
9
Novice here.

I exported a macro to a Module and learned quite a bit. I am trying to do an unattended procedure which will delete many records in a series of tables. It would stop to ask if I really wanted to delete the records. I decided Keypress would work to answer the question (being completely ignorant of more elegant ways).

1. What is a better way to get Access not ask the question.

2. I notice it ran great with no questions as long as no other program was open. If I had Word open, I would get the "Y" inserted into my document and Access would then ask me the question. So do I need to make the function "private" or something?

Thanks.
 
if you turn off the warnings you won't get the message in the first place, so you won't have to answer it

docmd.setwarnings false 'turn off warnings
docmd.setwarnings true ' turn on warnings

you should include all your code within the two statements above, leaving the warnings off could mess up your application in other parts of your app if you want messages to be displayed.

Hope this helps,

ken
 
Just the kind of thing I was looking for. I knew there was a better mousetrap. Thanks.
 
Hi. There are a couple of methods for executing your query without calling the confirm dialog. Turning off ‘Confirm Action Queries’ works in most cases. However, some action queries will give you a dialog regardless of that setting.
The method I prefer is CurrentDb.Execute("SQL String"). Just replace “SQL String” with the SQL statement of your query and you’re good to go. One word of warning however, because the SQL statement is a string you’ll have to replace any quotation marks with apostrophes. You can find more information in the help file. But, here's and example:

CurrentDb.Execute ("DELETE tblHistory.* FROM tblHistory_
WHERE tblHistory.[Company]= 'AVL';")

Good luck and welcome to the delightful world of VBA!

~Abby
 
Abby - thanks I will investigate your approaches.

I picked up a "Visual Basic 5 Database, How-To" book published by Waite Group Press for 10% of its original price. It is a thick book but not really a see spot run learning kind of book. However between that, help and converting macros, I am approaching overload - but having fun!
 
If I am not mistaken ther is an option in the Tools, Option menu of acces to disable the warnings when action queries are executed.

Hope this helps.
 
Alexandre - looked there in my Access 97 - no day
smile.gif
Seem to remember that too, from class or when I was on another system. Probably is in Access 2000.

The turn warnings off and on worked great in the function. I am doing this for a client, so I want to make sure they have the protections of warnings if they want.

Thanks
 

Users who are viewing this thread

Back
Top Bottom