Jun 9 2005, 10:16 AM
is there anyway in VBA that i can disable warning messages, such as Append msgs, or Insert,
what im doing is updating a table when a button is clicked and i don't want to have to click on OK to update after that?
Jun 9 2005, 10:18 AM
its ok i got it DoCmd.SetWarnings(false)
Jun 9 2005, 10:37 AM
yes you can set the warning false before the query run code and then don't forget to set them back on afterwards (true). Only problem is that if an error occures while you run the query it won't display it. There is another method with error handling, but if you don't care about that little con then go ahead and use setwarnings = flase
Jun 9 2005, 10:40 AM
so go on whats the little con???
Jun 9 2005, 10:47 AM
The little con (contra) for using setwarnings falls is:
Only problem is that if an error occures while you run the query it won't display it
If you are asking for the other methods.
Well you can use the execute command which doesn't require to set warning false and true and supposedly it is faster as well if you have huge queries.
CurrentDB.Execute "DELETE * FROM MyTable WHERE ID = 5", dbFailOnError
For more options check: action query run FAQ's
Jun 9 2005, 10:55 AM
do you by any chance know how to loop though the results of an sql query?
what i want to do is basically count how many records the qry returns (all in VBA of course!)
Jun 9 2005, 11:16 AM
just use the cound or Dcount function to count the records in a query/table.
if you want to display the number in a txtbox on a form in the recordsource of the txtbox put:
Count(*) to return even blank records (isNull)
use Dcount if you want to return a specific number like:
DCount("[ShippedDate]", "Orders", "[ShipCountry] = '" & strCountry & _ "' AND [ShippedDate] > #" & dteShipDate & "#") Returns the number of orders in the Orders table that were shipped to a specified country/region (strCountry) after a specified ship date (dteShipDate). The domain is the Orders table.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here