Category Archives: Function Library

The Function Library contains single procedures of VBA code that can be used in your projects

ExportToCSV

The following code will Export data to a CSV file. You can pass a Table name Query name, or an SQL statement to it. If you pass an SQL statement, be sure to wrap it with parenthesis. The procedure is declared as a Function for convenience and will always return a 0. The convenience being referenced, is that of adding the function call directly to that OnClick procedure of a Button control with something like this in the On Click property:
Continue reading

EvalMixedNum

This function is similar to the builtin Eval function, but instead returns the value of a mixed number (ex. 1-1/4). This is useful in situations where the user might be entering a size dimension into an unbound field, or other situations where a user may desire to enter a fractional value in an unbound field.
Continue reading

EqualGrouping

The function attempts to divide a given number of discrete items into equal groups and minimize the number of groups needed. This is useful for scenarios where you may want to avoid layouts where you have 4 items on first page and only 1 items on second page. Running 5 items for maximum of 4 through the function will return { 3, 2 }, enabling you to know that you’d put 3 items on one page and 2 on next page.
Continue reading

CloseAllForms

Closes all open Form objects unless the name of the form has been passed to the function as an exclusion (you can pass multiple form names as being ‘Excluded’). Returns a byte value of 0. The reason for creating this procedure as a Function is that you have to ability to set the OnClick event of a button to: =CloseAllForms() and thus avoid a “one-liner” of [Event Procedure] VBA code to call the procedure.
Continue reading

Base Ten to Base Letter

This is a pair of related functions for use in VBA. For alternate methods while working in Excel and within a limited range, see the Alternative Excel Implementation section.
Continue reading