Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check Program Language & How do I Activate?

Status
Not open for further replies.

Kurt6905

Technical User
Aug 21, 2006
14
0
0
US
I have a question for any VB expert out there. I have the following module written for Access 97, however, the Run button will not activate. What needs to be done to run the program? And is the program language correct?

(Additional info - the table is named Structural 2005. The fields Amount, Units, and Formulation are used to calculate the field Active. All amounts are entered and waiting for calculation. I want this module to calculate to Active every record in one sweep - about 10,000 records.)

Option Compare Database
Option Explicit
Function DoTheUpdates()
docmd.set warnings false

DoCmd.RunSQL "update [Structural 2005] set Active = Amount * 8.35 * Formulation * 0.01 where Units= 'GAL'"

DoCmd.RunSQL "update [Structural 2005] set Active = Amount/16 * Formulation * 0.01 where Units= 'OZ'"

DoCmd.RunSQL "update [Structural 2005] set Active = Amount * Formulation * 0.01 where Units= 'LBS'"

docmd.set warnings true
End Function

Thanks for any assistance!

 
Your function looks correct, and the SQL statements look syntactically right as well. Can you post the code for the Run button (ie cmdRun_Click).

Basically I would expect to see within the sub, a call to
DoTheUpdate to run the code within it.

John
 
The storing of calculated data is not usually a good idea. If any of the other data gets changed, your calculated field is now invalid and could jeopardize the accuracy of any reports that use it. It is normally preferable to perform the calculation at the time it is needed (for example, when preparing to print or display a report).


Randy
 
Replace this:
docmd.set warnings
with this (2 times):
DoCmd.SetWarnings

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top