Custom functions work the same way as MS Access built-in functions such as DateAdd, DatePart and DSum, but are instead created ourselves as database developers. We do this by creating a public function with the VBA programming language and save it inside a global module within the database. Today I am going to explain how custom functions can be…
Use TryGet pattern for transient values
A number of objects may have extra properties or something where it might not exist for all instances. A good example might be finding property on an variable: Not all controls have a property and thus can fail to run. A common approach is to use OERN: This will work OK but this can significantly…
Access InStr() function to SQL Server equivalent
What is the SQL Server equivalent to Access InStr() function? TargetField: String expression being searched SearchValue: String expression being sought StartPosition: Starting position for each search (optional) Access SQL SQL Server
Access 2010: Unrecognized Database Format
I’ve been seeing more and more people having problems with the Unrecognized Database Format when creating or modifying an Access 2007 (accdb) format database in Access 2010 and then trying to open it again in Access 2007. The issue appears to be that Access 2010 does not have its own file format. When you add a…
#LateBind Constant
In standard code, we make use of #LateBind conditional compilation constant, which is typically defined via project’s Conditional Compilation Argument in the dialog: NOTE: The dialog can be found via Tools → <project name> Properties, which is located below the Options menu item. The menu item caption will be different as it includes the project…
Designing a lookup table with logic
It is very common for us to embed some kind of logic based on a lookup table or in some cases, a column of a table. Because we have application logic connected to it, the code are fragile and subject to changes as the requirements develops. We want to avoid this situation where we might…
Use controls, not fields
Sometimes we need to use fields from a RecordSource that aren’t shown on the form. It is legal to reference them directly even if they don’t have a control. For example, we can have a form bound to a RecordSource like so: And only display in a textbox but not show the . In code,…
Access IIf() function to SQL Server equivalent
What is the SQL Server equivalent to Access IIf() function? Access SQL SQL Server