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!

Expression Builder

Status
Not open for further replies.

colval

MIS
Feb 24, 2011
49
0
0
GB
Hi

We have several fields on a form that have After Update expression next to it.

For example =calcmaterialrisk and is place in After Update. when I go into the expression builder it just says =calcmaterialrisk

I can see it is made of several tables for example listasbestostype with the fields Description, factor and ID. It is using the Factor to add the figures from each table and then places the result in a filed called MaterialRisk.

What I cant figure out is how the =calcmaterialrisk is working as it just shows like this in the expression builder.

Thanks
 
calcmaterialrisk is referring to a function located in the VBA code of either the form or one of the modules. Usually if you click the 3 dots off to the right side, it will take you right to the appropriate code.
 
When I click on the ... dots it just takes me into tne Expression builder where it just as the code =calcmaterialrisk

I have found it in the modules but still not certain how it actually adds the ratings up.
 
The code you found in the modules is most likely evaluating form fields and calculating the MaterialRisk. So I'm guessing you will find the =calcmaterialrisk in the AfterUpDate event of any field that affects that calculation, and maybe the Open event of the form. I think what you may want to do is use debug mode to step through that calcmaterialrisk function and examine exactly how it is arriving at its result.
 
Hi

You are right it is in afterupdate event.

Yes that would be a good idea, however, when I try and run the debug mode it comes up with a box asking to name a Macro box or nothing is in the box and the DB does not use macros. I thought it would just step through the code. I have tried playing with the settings but still get the message, any ideas?

Thanks
 
It sounds like you didn't set a breakpoint to pause the code. Open the Visual Basic Editor, go to the calcmaterialrisk function, and click on a line of code after the Dim statements. Press F9 to set a breakpoint on that line (should turn red). Open the form and update one of the fields. As soon as the calcmaterialrisk is called it will pause at your breakpoint. Press F8 to execute one line at a time, or F5 to continue to your next breakpoint, or exit function if you haven't set another. You can see most variable values by hovering over the variable in the code, or press CTRL G to openthe immediate window and type ? WhateverVariable to display its current value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top