Probably the most common requests we see in forums is for an 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

I was trying to help mezentia on UtterAccess.com with getting a list of files contained within a folder with their properties (size, date created, date modified, last accessed, …) and 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(), 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. That said, if all you are after is the size of a file, there is no need to resort to using FSO, when you can get the same information with a single function, the FileLen() function!

As indicated in my sample database, if you are looking for some referencing on the subject of File System Object, I suggest you start with:
http://msdn.microsoft.com/en-us/library/ea5ht6ax%28v=vs.84%29.aspx
http://ss64.com/vb/filesystemobject.html

Just as a demonstration, here is a simple example of using FSO to get some basic file properties

                  '---------------------------------------------------------------------------------------                  ' Procedure : GetFileInfo                  ' Author    : Daniel Pineault, CARDA Consultants Inc.                  ' Website   : http://www.cardaconsultants.com                  ' Purpose   : Retrieve some basic file information                  ' Copyright : The following may be altered and reused as you wish so long as the                  '             copyright notice is left unchanged (including Author, Website and                  '             Copyright).  It may not be sold/resold or reposted on other sites (links                  '             back to this site are allowed).                  ' 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:                  ' ~~~~~~                  ' GetFileInfo "c:\Tests\myXLS.xls"                  ' GetFileInfo "c:\Tests\myMDB.mdb"                  '                  ' Revision History:                  ' Rev       Date(yyyy/mm/dd)        Description                  ' **************************************************************************************                  ' 1         2017-09-01              Initial Release                  '---------------------------------------------------------------------------------------                  Public                  Function                  GetFileInfo(ByVal                  sFile                  As                  String)                  On                  Error                  GoTo                  Error_Handler                  Dim                  fso                  As                  Object                  Dim                  f                  As                  Object                  Set                  fso =                  CreateObject("Scripting.FileSystemObject")                  Set                  f = fso.GetFile(sFile)       Debug.Print                  f.Name                  'Could also use f.Name if we wanted to                  Debug.Print                  ,                  "Size: "                  & f.Size                  'We could just as easily use FileLen(sFile)                  Debug.Print                  ,                  "Created: "                  & f.DateCreated     Debug.Print                  ,                  "Modified: "                  & f.DateLastModified     Debug.Print                  ,                  "Accessed: "                  & f.DateLastAccessed     Debug.Print                  ,                  "Type: "                  & f.Type                  Debug.Print                  ,                  "Attributes: "                  & f.Attributes   Error_Handler_Exit:                  On                  Error                  Resume                  Next                  Set                  f =                  Nothing                  Set                  fso =                  Nothing                  Exit                  Function                  Error_Handler:     MsgBox                  "The following error has occurred."                  & vbCrLf & vbCrLf & _                  "Error Number: "                  & Err.Number & vbCrLf & _                  "Error Source: GetFileInfo"                  & vbCrLf & _                  "Error Description: "                  & Err.Description, _            vbCritical,                  "An Error has Occurred!"                  Resume                  Error_Handler_Exit                  End                  Function                

'--------------------------------------------------------------------------------------- ' Procedure : GetFileInfo ' Author : Daniel Pineault, CARDA Consultants Inc. ' Website : http://www.cardaconsultants.com ' Purpose : Retrieve some basic file information ' Copyright : The following may be altered and reused as you wish so long as the ' copyright notice is left unchanged (including Author, Website and ' Copyright). It may not be sold/resold or reposted on other sites (links ' back to this site are allowed). ' 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: ' ~~~~~~ ' GetFileInfo "c:\Tests\myXLS.xls" ' GetFileInfo "c:\Tests\myMDB.mdb" ' ' Revision History: ' Rev Date(yyyy/mm/dd) Description ' ************************************************************************************** ' 1 2017-09-01 Initial Release '--------------------------------------------------------------------------------------- Public Function GetFileInfo(ByVal sFile As String) On Error GoTo Error_Handler Dim fso As Object Dim f As Object Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile(sFile) Debug.Print f.Name 'Could also use f.Name if we wanted to Debug.Print , "Size: " & f.Size 'We could just as easily use FileLen(sFile) Debug.Print , "Created: " & f.DateCreated Debug.Print , "Modified: " & f.DateLastModified Debug.Print , "Accessed: " & f.DateLastAccessed Debug.Print , "Type: " & f.Type Debug.Print , "Attributes: " & f.Attributes Error_Handler_Exit: On Error Resume Next Set f = Nothing Set fso = Nothing Exit Function Error_Handler: MsgBox "The following error has occurred." & vbCrLf & vbCrLf & _ "Error Number: " & Err.Number & vbCrLf & _ "Error Source: 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.

Feel free to download the sample ms access (2007 -accdb) database by clicking on the link below:

Sample File Listing and Property Database

Please note that although the sample db is an access 2007 accdb, there is nothing used in this sample that would not run in Access 2000, 2003, … If you want or need to downgraded the database format, feel free, it will work.

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:

  • How to determine who is logged on to a database by using Microsoft Jet UserRoster in Access
  • Who's Logged On / Who's Connected
  • Miscellaneous Library (see the heading WhosOn97)

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);

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 1905 times – 33 KB

Version History

V1.000 (2018-10-18)

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/slidder.

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.

Just another nifty method to add a little wow factor to a form.

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

Updated

The download now includes both horizontal and vertical slider examples.

Sliding/Shutter Subform Example Download

This database demonstrates how to insert a clock in your forms to display the current time as well as a demonstration of how to create a timer used to determine the amount of time which a form has been open for.

Download the sample database: MS Access Clocks and Timers Sample Database

This database demonstrates some of the most common ways to work with dates. It demonstrates how to extract only a part of a date (year, month or day), how to display a date in different formats (ISO, American,…), how to determine the number of days, weeks between 2 dates, etc.

Download the sample database: MS Access Working with Dates Sample Database

This database example show the proper way to work with images within a database (which is not to embed them into the database).

Download the sample database: MS Access Images Sample Database

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.

This database provides a single form which permits the user to either import or export data to/from the database from a selected source (spreadsheet).

Download the sample database: MS Access Data Transfer Sample Database

This is a very simple database which provides the user a form which permits them to convert color values between OLE Color values, RGB values and HEX values.

MS Access Color UtilityAs you can see by the above you can enter a OLE Color, RGB Color, HEX color value, move sliders (if you were trying to find a color) and they get converted back and forth between all the formats in real-time and you get a visual of the color in question at the top of the form.

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 - Color Converter Utility (mdb x32)" Colors.zip – Downloaded 2938 times – 31 KB

Version History
V1.000 (2010-11-17) Initial Release