Is there an intro tutorial for writing code for forms? I've never done it before & I'm winging it based on my knowledge of MS AC/XL VBA and the gridtable.odb example I downloaded from Forum.openoffice.org > Board index > Getting started > Tutorials > Base > Database Examples > [Example] Searching in a form with macros
If anyone wants to help in this thread, here are the details:
- DB Name: ProdDB.odb
- Form Name: frmTrips
- 3 Numeric Field controls on the form:
- nbrStartMileage
- nbrEndMileage
- nbrCalculatedDistance
- Trying to write code to calculate the difference between nbrStartMileage and nbrEndMileage, then populate nbrCalculatedDistance with that difference. Trying to get this calculation/population to take place when nbrEndMileage loses focus.
- Created a module in ProdDB.odb > Standard named modFrmTrips
- Created a procedure in Standard.modFrmTrips named nbrEndMiles_LoseFocus. Wrote the following code in this procedure:
Code: Select all
Sub nbrEndMiles_LoseFocus(pobjEvent as object) dim pobjForm as object dim pintStartMiles as integer dim pintEndMiles as integer dim pintDrivenMiles as integer pobjForm=pobjEvent.Source.Parent pintEndMiles = pobjForm.nbrEndMileage pintStartMiles=pobjform.nbrStartMileage pintDrivenMiles = pintEndMiles-pintStartMiles pobjform.nbrCalculatedDistance.Value = pintDrivenMiles End Sub
- In frmTrips form > nbrEndMileage Numeric Field control > When losing focus event, I linked to the procedure above
Thank you for any help anyone can provide,
CTB