Suppose you have an Access Database containing the names and addresses of your customers. Every now and again you may want or need to send a standard letter to each customer who has opted in to such mailings. However, you are aware that these letters are going to look so much better, and work so…
“Truthy” and “Falsy” Values
VBA is quite very loose in what it deems “truthy” and “falsy”. For example, this procedure can produce surprising result: If Me.MyBitField.Value = True Then ‘It is true Else ‘It is false End If At the first glance, it seems expected that if the bit field is set to 1, it would succeed. But in…
Prefer compile time errors over run time errors
In VBA, there are several features that allow us to do things that may not be checked at the compile time. In particular, it is possible to write several late-bound expressions which means that it can potentially contain run-time errors. One common misconception about late-binding is that it’s a matter of adding a reference and…
Access 2003 Technical Articles
In this section of the MSDN Library, you’ll find technical articles that demonstrate how to build and deploy complex Access 2003 runtime-based solutions, automate Access from another application; use the new XML features in Access 2003, and even how you can animate Access 2003. You can use the TOC to your left to navigate through…
Access IIf() function to SQL Server equivalent
What is the SQL Server equivalent to Access IIf() function? Access SQL IIf([ResultValue]>=1, [Result Value], Null) SQL Server CASE WHEN [Result Value]>=1 THEN [Result Value] ELSE NULL END
Access UPDATE query to SQL Server
How do I convert an Access UPDATE query to SQL Server? Access SQL UPDATE Cars INNER JOIN UpdateList ON Cars.Parts = UpdateList.Parts SET Cars.Price = [Updatelist].[price] SQL Server UPDATE Cars SET Cars.Price = [Updatelist].[price] FROM Cars INNER JOIN UpdateList ON Cars.Parts = UpdateList.Parts
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 Controlsource property on an Access.Control variable: For Each ctl In Me.Controls Debug.Print ctl.ControlSource ‘A potential error Next Not all controls have a ControlSource property and thus can fail to run. A…
Why does Excel have a problem when using code in Access?
When you use code to refer to Excel (and other programs as well) you need to be careful not to use any code that does not refer back to the instantiated application object. If you do so then you will find that Access instantiates another Excel (or other program) object which is not visible to…
Creating a Make Table Query
Before we create the Make Table Query, you might like to create a new blank database file. This is so we have a separate database into which we can paste the new table from the query. In this exercise I have called it HistoricData.accdb. Here is the procedure to create a Make Table Query: Open…
Using Custom Functions in Calculated Controls
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…