Category Archives: Programming

Calculated Fields in CiviCRM

One of CiviCRM’s strengths is the ability to add custom fields to hold specific information about your contacts. One thing it doesn’t offer (yet) is a calculated field type that will present the results of calculations of other fields.  While calculated fields are generally discouraged in relational database design, they are sometimes necessary within a user interface. One suggested method is to add custom code hooks within CiviCRM’s PHP code but as a database guy, I decided on a back-end solution.

Continue reading

MySQL User Defined Function Example: Data Cleanup

(Updated June 9, 2016)

The Challenge

One of my current projects involves migrating a large amount of data away from an old custom Borland Paradox application into a new CiviCRM system. As with too many quickly-constructed apps, this old Paradox database wasn’t especially well designed and, among other the other challenges in salvaging the data, there were no restrictions on how dates could be entered. This means that, in multiple fields within each of the 20,000+ database records, I might see any of the following:


While CiviCRM does have a utility for importing data from CSV and other SQL tables, it was having quite a time with this collection and many of the dates were being mishandled. That’s if the records weren’t rejected entirely for other reasons. Data migration doesn’t often happen with just a few settings adjustments and a click of the Import button.

Continue reading

Coding Basics – Deceptively Simple Programming

In my last post on coding basics, I talked about turning an algorithm into code and used Euclid’s Algorithm as an example of programming a sequence of steps. There’s an even simpler type of algorithm that I want to look at this time. A formula, such as the one for converting Fahrenheit to Celsius, is also a series of steps that must be performed in order to achieve the needed result. These calculations can be represented within C# or other programming languages to include the formula as part of a larger program.

If you’re doing a one-time conversion from Fahrenheit to Celsius, you’re probably going to pull out your pocket calculator or find a good conversion website and enter the necessary numbers. You can do that because either of those resources has the necessary interface to get the necessary input from you. If you’re including this calculation in a program, you need to design your own interface, process that user input from it and return the result to the user in some way. In the case of the pocket calculator or website, other programmers pondered these issues at some point and now it’s your turn.

Continue reading

A Return to Programming

I’ve been working on a number of different projects lately, from I.T. networking to a book on MySQL, so I haven’t had as much reason to break out the programming tools as I used to. If not used regularly, programming skills can get a little rusty or even disappear like old friends from your college days that you lost contact with.

So, I’ve decided to delve back into the subject and update my status as a .NET programmer. The first step is a quick review of the C# language.  One resource that I can recommend for this is The C# Programming Yellow Book by Rob Miles. It’s just $0.99 for the Kindle version on and you can even get a free PDF version from the author’s website.

Continue reading

From Algorithm to Code

In previous articles, I’ve talked about the importance of finding the right algorithm, or series of steps to follow, when coding a solution. Efficiency in terms of the amount of memory used and the amount of time taken by the operation are key factors for the program. Sometimes an appropriate algorithm is already available and in wide use and it’s just up to the programmer to turn it into code. There’s always the option of running to StackOverflow and grabbing some code but that does nothing to further your talent.

Continue reading

Adding Passswords to Microsoft Access Switchboard Options

The Switchboard Manager in Microsoft Access makes it easy to create a system of menus that will enable your users to navigate through your application. It also relieves you of the need to manage multiple menu forms and macro calls.

Microsoft Access switchboard form

Figure 1 – Example Access Switchboard

Sometimes, however, you might want to keep all but a few users out of specific areas, even if it’s just a password to discourage the curious. This is one thing the Switchboard Manager doesn’t offer and I’d like to show you one method for achieving this here. I want to stress that this method is not truly secure.  On it’s own, it won’t prevent a user from hitting F11 and browsing through the database. A power user who wants to see those areas could defeat this method pretty quickly. It will keep the merely curious and inexperienced users out, however, and could be combined with other measures to add more security.

Continue reading

Fixing the Orange (or Red) Status Icon in WampServer

As part of my latest project, I decided to try out WampServer, the Windows development environment for developing web applications with Apache web server, MySQL database and PHP scripting (Windows, Apache, MySQL, PHP – WAMP). Packages like WampServer and EasyPHP are simplified ways to create a testing environment on your PC without spending a lot of time downloading, installing and configuring the individual components. The package also includes utilities such as PHPMyAdmin and SQLBuddy for managing your MySQL databases and writing SQL queries. The software is available in 32- and 64-bit versions and the installation is pretty straightforward.

Continue reading

What is Recursive Programming?

When writing programs, it’s often necessary to perform repeating operations on collections of items such as customer orders or invoices.  Often, you can just iterate through the collection or count the items to determine how many times to perform the operation.  When working with a hierarchy of items such as a directory structure where you have an unknown and varying number of levels under each branch, it’s a different story.  For this, the typical method is to use recursive programming, often just called recursion. This is a method in which one routine is designed to analyze the items on one level of the hierarchy, look for any sublevels and then call itself to analyze each sublevel.  Each time the routine calls itself, it creates another instance of itself that works independently until it’s finished and then returns to the instance that called it.

Continue reading

Using Visual Studio to Manage Your Data

(This article was updated in August 2018 for use with Visual Studio 2017.)

Moving Beyond Microsoft Access

I’ve written a lot about Microsoft Access over the years and still believe it’s a great training ground for people who want to learn to design database applications. Its user-friendly interface provides an easy learning curve and introduction to the basics of relational databases, data entry forms and report design. If you want to get serious about programming, however, it’s important to expand your skillset beyond Access with tools that are in demand by potential employers and customers.

One of these tools is Microsoft Visual Studio, the development suite that provides access to the .NET family of languages including C# and VB.NET. With Visual Studio, you can create a variety of professional applications from Windows form applications to websites powered by ASP.NET. While Microsoft Access provides some impressive tools for the office power user and even some full-time programmers, Visual Studio is the next step up the development ladder. It enables professional programmers to design any type of solution without being tied to a Microsoft Office installation and without the limitations of the Windows desktop. A couple quick searches of sites like will show you the kind of jobs and salaries that knowledge of Visual Studio can lead to as opposed to Microsoft Access.

Continue reading