gavinclarke
Jun 9 2005, 10:16 AM
hi again,
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?
gavinclarke
Jun 9 2005, 10:18 AM
its ok i got it DoCmd.SetWarnings(false)
freakazeud
Jun 9 2005, 10:37 AM
Hi,
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
HTH
Good luck
gavinclarke
Jun 9 2005, 10:40 AM
so go on whats the little con???
freakazeud
Jun 9 2005, 10:47 AM
The little con (contra) for using setwarnings falls is:
QUOTE
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.
E.G.:
CurrentDB.Execute "DELETE * FROM MyTable WHERE ID = 5", dbFailOnError
For more options check:
action query run FAQ's HTH
Good luck
gavinclarke
Jun 9 2005, 10:55 AM
ok, thanks!
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!)
freakazeud
Jun 9 2005, 11:16 AM
Sure,
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([YourIDField])
use
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.
HTH
Good luck
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.