AccessBlog.net

News, links, downloads, tips and tricks on Microsoft Access and related

About Me Search
Alex
Name:Alex Dybenko

Location:Moscow, Russia

Sunday, December 21, 2008

Events on query datasheet

One more interesting sample by Krzysztof Naworyta, Access MVP - lightweight form events. Imagine that you open a select query and want to run some code on Unload or AfterUpdate event. Looks like Access does not offer such opportunity, but it is! Using Screen.ActiveDatasheet you can get a reference to query’s form object and then work with it as normal Access form. Same applies to tables/queries as subfoms. Run the sample and look at VBA code to learn this technique.

Labels: ,

Friday, December 12, 2008

How to avoid #Error in expressions

If you have a form with subform, last one has no records, and you have a textbox on a main form which calculates total – then you can get #Error as a result of your calculation.

Error

You can simply avoid this using IsError() function, just make the expression like this:

=IIf(IsError([frmMySubform].[Form]![txtTotal]),0, [frmMySubform].[Form]![txtTotal])

Labels: