Tag Archives: Database Samples

Free Nonprofit CRM Template to Organize Contacts and Members

Over the years, I’ve worked with several charities to help them get their data organized. One of the most common challenges they face is keeping track of their contacts, clients, and members in a clear and consistent way.

Many of these organizations, through no fault of their own, simply don’t have the resources or technical expertise to build a professional database solution. Instead, they often make do with a mix of spreadsheets, usually in Excel, stitched together to somewhat meet their day-to-day needs.

To make things a little easier, I’ve decided to share a simple, bare-bones sample database that can serve as a solid starting point. From here, new features and functionality can be added over time, but this foundation gives non-profits a reliable and well-structured beginning.
 
Continue reading

MS Access Contact Database Template Sample

Probably the most common requests we see in forums is for an Microsoft Access Contact database templates and how to structure the tables and build the data entry forms.  So I thought I’d provide a basic sample database to help beginners get off to a good start.

The basic structure that I created is as follows:

Contact Database Relationships and then I created a simple form to manage everything from:

Contact Database Form

This is a simple sample as things can get very complex, very quickly depending on your needs, but for the average home user this would fill the need for a contact management database or at the very least be a great starting point to build more complex applications from.

This demo is unlocked and fully editable with no strings attached.

Continue reading

VBA – List of Files within a Folder and Get their Properties

I was trying to help user mezentia on UtterAccess.com with getting a list of files contained within a folder with their respective properties (size, date created, date modified, last accessed, …), below is a link to the particular discussion thread:

finally created a small demo database to illustrate how it could all be pieced together in a seamless manner. As I have seen a number of similar questions over the years, I thought I would add it to my blog in the hopes it may help someone else out.

Although there are a few build-in functions (such as: FileLen() – do not FileLen() as it is unreliable!, FileDateTime()), because we needed other more advanced properties, at the end of the day, the easiest method to get such information is to use the File System Object (FSO) to extract the relevant information regarding each file and I demonstrate how this is done.

To illustrate how you can use FSO, here is a simple VBA example of how you can get some basic file properties

'---------------------------------------------------------------------------------------
' Procedure : FSO_GetFileInfo
' Author    : Daniel Pineault, CARDA Consultants Inc.
' Website   : http://www.cardaconsultants.com
' Purpose   : Retrieve some basic file information
'               Right now, print result to the VBA immediate window
'               Could return an Array, Dictionary Object, ...
' Copyright : The following is release as Attribution-ShareAlike 4.0 International
'             (CC BY-SA 4.0) - https://creativecommons.org/licenses/by-sa/4.0/
' Req'd Refs: Uses Late Binding, so none required
'
' Input Variables:
' ~~~~~~~~~~~~~~~~
' sFile     : Fully qualified path & filename with extension of the file to report on
'
' Usage:
' ~~~~~~
' FSO_GetFileInfo "c:\Tests\myXLS.xls"
' FSO_GetFileInfo "c:\Tests\myMDB.mdb"
'
' Revision History:
' Rev       Date(yyyy/mm/dd)        Description
' **************************************************************************************
' 1         2017-09-01              Initial Release
' 2         2021-12-19              Updated proc Name, variable naming to standardize
'                                   Added all available properties
'                                   Added Early Binding sample declarations
'                                   Updated Copyright
'                                   Minor update to inline comments
'---------------------------------------------------------------------------------------
Public Function FSO_GetFileInfo(ByVal sFile As String)
    On Error GoTo Error_Handler
    'Early Binding
    '**********************************************************************************
    '    'Requires a reference to 'Microsoft Scripting Runtime' library
    '    Dim oFSO                  As Scripting.FileSystemObject
    '    Dim oFSOFile              As Scripting.File
    '
    '    Set oFSO = New FileSystemObject
    'Late Binding
    '**********************************************************************************
    Dim oFSO                  As Object
    Dim oFSOFile              As Object

    Set oFSO = CreateObject("Scripting.FileSystemObject")
    '**********************************************************************************
    '**********************************************************************************
    'Invariable Code regardless if Early or Late Binding is used
    Set oFSOFile = oFSO.GetFile(sFile)

    With oFSOFile
        Debug.Print "Attributes:", .Attributes
        Debug.Print "Created:", .DateCreated
        Debug.Print "Accessed:", .DateLastAccessed
        Debug.Print "Modified:", .DateLastModified
        Debug.Print "Drive:", .Drive
        Debug.Print "Name:", .Name
        Debug.Print "Parent Folder:", .ParentFolder
        Debug.Print "Path:", .Path
        Debug.Print "Short Name:", .ShortName
        Debug.Print "Short Path:", .ShortPath
        Debug.Print "Size:", .size                'Remember FileLen() is unreliable!!!
        Debug.Print "Type:", .Type
    End With

Error_Handler_Exit:
    On Error Resume Next
    If Not oFSOFile Is Nothing Then Set oFSOFile = Nothing
    If Not oFSO Is Nothing Then Set oFSO = Nothing
    Exit Function

Error_Handler:
    MsgBox "The following error has occurred." & vbCrLf & vbCrLf & _
           "Error Number: " & Err.Number & vbCrLf & _
           "Error Source: FSO_GetFileInfo" & vbCrLf & _
           "Error Description: " & Err.Description, _
           vbCritical, "An Error has Occurred!"
    Resume Error_Handler_Exit
End Function

The demo illustrated how the above can be adapted to inventory a whole directory of files and log it to a table for easy review.

Disclaimer/Notes:

If you do not have Microsoft Access, simply download and install the freely available runtime version (this permits running MS Access databases, but not modifying their design):

Microsoft Access 2010 Runtime
Microsoft Access 2013 Runtime
Microsoft Access 2016 Runtime
Microsoft 365 Access Runtime

All code samples, download samples, links, ... on this site are provided 'AS IS'.

In no event will Devhut.net or CARDA Consultants Inc. be liable to the client/end-user or any third party for any damages, including any lost profits, lost savings or other incidental, consequential or special damages arising out of the operation of or inability to operate the software which CARDA Consultants Inc. has provided, even if CARDA Consultants Inc. has been advised of the possibility of such damages.

Download a Demo Database

Feel free to download a 100% unlocked demo copy by using the link provided below:

Download “Access - List Files and Get File Properties (x32 accdb)” GetFileListAndSpecs.zip – Downloaded 62955 times – 48.48 KB

Extended Properties

If you are looking to retrieve Extended Properties, Exif Properties, …, things that cannot be retrieved using FSO, be sure to check out my article on the subject:

A Few Resources on the Subject

MS Access – Who is Logged In?

Another common need for most database administrators & developers is to be able to see who is logged into a database. A very common solution to this in the past has been to use the Jet UserRoster, see:

I personally find much more useful to create a table to log the database usage by the users and have a form open in hidden mode at the database startup to populate the table in question. There is also the added benefit that this method permit much more detailed information, and historical review (not possible with the UserRoster). The historical data can be very useful when determining users that did not disconnect properly (which can lead to corruption) from the database. The extra information can also be useful when troubleshooting problems.

So how can you create this simple log tracking form? Very easily and here is how:

  1. First, we need to create a table to log the comings and goings within our database. Please note that you can add or remove the quantity (number of fields) you wish to keep track of. To do so you can use the following Data Definition Language (DDL) to create the corresponding MS Access table:
CREATE TABLE tbl_Db_UserTracking 
   (UTEntryID AUTOINCREMENT PRIMARY KEY,
   OSUserName VARCHAR(255) NOT NULL,
   ComputerName VARCHAR(255),
   ComputerIP VARCHAR(20),
   DbEntry datetime NOT NULL,
   DbExit datetime);
  1. Then we need to create a login tracking form which will get open at startup in a hidden mode (so the user never actually sees it). Below is one example of this form. Since the form is never actually visible, you need not waste any time formatting it or performing any special layout… A bare minimum is required.
  2. Then we need to setup a method to automatically launch the form at startup. Since all of my databases use an AutoExec macro to perform a number of steps (relink the table, check user permissions, stratup logoff forms, …) at starup it is only logical to merely add this to the function that the AutoExec macro calls.
  3. Then we need to create a form for the administrator to use to review the data.

Disclaimer/Notes:

If you do not have Microsoft Access, simply download and install the freely available runtime version (this permits running MS Access databases, but not modifying their design):

Microsoft Access 2010 Runtime
Microsoft Access 2013 Runtime
Microsoft Access 2016 Runtime
Microsoft 365 Access Runtime

All code samples, download samples, links, ... on this site are provided 'AS IS'.

In no event will Devhut.net or CARDA Consultants Inc. be liable to the client/end-user or any third party for any damages, including any lost profits, lost savings or other incidental, consequential or special damages arising out of the operation of or inability to operate the software which CARDA Consultants Inc. has provided, even if CARDA Consultants Inc. has been advised of the possibility of such damages.

Download a Demo Database

Feel free to download a 100% unlocked demo copy by using the link provided below:

Download “Access - Who's Logged In (x32 accdb)” WhosLoggedIn_V1.000.zip – Downloaded 50335 times – 33.27 KB

Version History

V1.000 (2018-10-18)

MS Access – Sliding/Shutter Subform Example

I was looking for a simple way to reproduce a web style expandable sidebar (accordian subform, expandable subform, sliding subform, shutter subform, or whatever name you’d like to use to describe it in MS Access), instead of merely making a subform visible/invisible. The attached file, does exactly that and with a single change to a constant variable you can control the speed of the shutter/slider.

This is a very crude example to illustrate the principle.  You can use any subform you like, within any form you’d like.  There are no requirements to make this work and all the code is native MS Access code, no external references, or ActiveX Controls.  The button used to expand and retract the subform can also be changed as you see fit, it is just a question of placing the brief code behind whatever button you select to use in your design.

Continue reading

MS Access Sample – Change Password

If you are using user-level security (ULS), the following is a simple demonstration of a form that can be added to any database to permit the user the ability to change their password. Useful when you create an mde or disable the standard toolbars for increased security but still want to give the user the ability to rotate their own password.

Download the sample database: User-Level Security Change of Password Form Demonstration.

Special Note & Warning
Be very careful using this sample.  If you run it on a database which does not have a designated mdw security database assigned, it will alter the system.mdw, thus affecting ALL your databases!  It is only meant to be run on secured databases using ULS security.  Any other applications can have disastrous results on your databases.  I mention this because I recently was e-mail by someone who made this mistake.  Below is the solution to fix such a mistake:

So if I understand the situation properly, you ran the chgPwd.mdb on your computer, in a db, or on its own in a db that wasn’t already secured?  I would assume that by doing so you inadvertantly applied a password against your system mdw database.  So in fact you secured the master system.mdw database, thus imposing a password against all databases running on your computer.  The fix, you’d need to either reinstall Access, or copy over a system.mdw from another clean PC over to your.