Archive for ‘MS Access General Information’

January 21st, 2012

MS Access 2007-2010 Ribbon Development

MS Access Ribbon - Home Tab

 

A while back, ok several years ago, I took a look at the new (at the time it was new) ribbon.  I was interested in porting my Custom Toolbars into the new and improved format.  At the time I spent hours trying to digg up information on the subject.

To put things bluntly, MS messed up good on the implementation!

This is not to say that the ribbon is not a powerful tool and all the rest of that.

That said, it has been implemented in what I consider an incomplete form.  MS provides no tool, to develop custom ribbons, no built-in callback routines…, no access to the ribbon built-in images, and so many more flaws I don’t even know where to start!  It is a mess.

Then they still support old custom toolbars, but you have no way to edit, delete or work with them directly.  You have to revert back to using 2003 or prior, or develop your VBA own code to interact with them.

The whole situation smells bad.

So what is one to do.  First off, you have to realize, that the entire Office suite Ribbon is fully customizable and to work with it you can use a Custom UI Editor, EXCEPT for MS Access.  That’s right, as usual, MS Access is in a category of its’ own.  What a surprise!

Firstly, get ready to do a lot of reading, before you are even ready to tackle creating a ribbon.  Here are a few places to start:

www.accessribbon.de
http://www.andypope.info/vba/ribboneditor.htm
http://msdn.microsoft.com/en-us/library/aa338202(v=office.12).aspx
http://msdn.microsoft.com/en-us/library/bb187398.aspx

http://www.rondebruin.nl/ribbon.htm

For MS Access, try http://www.ribboncreator.de/en/  The ribbon creator is a graphical interface to create the required XML and VBA code.  Basically, what MicroSoft forgot to include in its’ own software!!!  At the very least it will speed up development and you can tweak what it generates.

All in all, the ribbon, because of the way MS has choosen to implement a half baked technology, is a miserable failure (from the developer’s perspective)!  Actually, even from the end-user’s perspective also.  Where I used to be able to load 6 toolbars containing 50 icons (or more) where I had all the commands I needed at my finger tips, I now have 1 ribbon containing 10-20 commands.  You end up spending your time flipping back and forth, all day, between tabs!  It is never ending and teadious after a while.  This is MS’ idea of empowering the end-user?  Come on!  But hey, it look cool dude!  This is the best that the best minds at MS could come up with; seriously!!!

That said, I believe MS has other plans for the ribbon, probably a way to introduce the end-user to the new layout, flow to be expected in future releases of their OS or other programs.  Let use not forget the fact tha t MS is playing a major game of catchup with MAC.

December 15th, 2011

MS Access – Splitting and Deploying Your Database – Part 2

In my previous post entitled Splitting and Deploying Your Database, I elaborated on the critical importance of splitting your database before deploying it to your end-users.  That said, many people post questions regarding securing their applications from their end-users to minimize their ability to mess around with the database, mainly fool around directly with the tables.  In this post I will elaborate on a few possible step you can take as a developer to best secure your database from what I qualify of ‘dangerous’ users.

There are a few things that you can do to try and harden your database against your users.  In 2 instances, you have the ability to take some steps using programming to secure your app.  In the 3rd, you can deploy your application in a secured method.  Let’s examine each.

 

Hide Object Pane & Disable SHIFT Bypass

As a developer, you can do your best to make it as difficult as possible for any user to gain access to any of your database objects (tables, queries, forms, reports, …) to pose a threat in the first place.  To do this you need to:

  1. Create an autoexec macro the uses RunCode to execute a VBA procedure at startup
  2. In your startup procedure add in the following code
If SysCmd(acSysCmdRuntime) = False Then
    DoCmd.SelectObject acTable, , <strong>True</strong>
    DoCmd.RunCommand acCmdWindowHide
End If

This code will hide the Access object browser (the pane that lists all the database objects: tables, queries, forms, reports, …).  If they can’t see them, then they can’t mess around with them!

  1. Since any knowledgeable user knows that they can bypass any autoexec macros by holding the SHIFT key at startup, we need to disable the shift bypass capacity.  Now there is no point in rehashing this subject, so please refer to: http://access.mvps.org/access/general/gen0040.htm

 

Convert to MDE

One more step you can take is to convert your database (mdb/accdb) to an (mde/accde) format.  By doing so you lockout the user’s access to the all the VBA code.  Furthermore, this creates a compiled version of the database which mean it should be optimized for use.  Win, win.  Just remember you cannot do development on an (mde/accde), so keep your original file (prior to conversion) for further development.

 

Deploy Your Database Using Runtime

The last thing you can do to restrict your users and limit their ability to run amuck in your database is to deploy your application using MS Access’s runtime version.  Instead of giving your user the full blown MS Access application, only install the free runtime version.  Unless, your user needs to do development in the database, there is no need for them to have the full version of MS Access.  By doing this, your user will not be able to edit any of the database objects!  They will only have access to whatever you have developed and given them access to.  Also, note that when deploying using the runtime version ensure you put in place error handling throughout all of your VBA procedures, otherwise when an error is raised, the application will blatantly crash.  You can freely download and install the runtime version of MS Access directly from Microsoft’s website at: 

MS Access Runtime 2007 -> http://www.microsoft.com/download/en/details.aspx?id=4438
MS Access Runtime 2010 -> http://www.microsoft.com/download/en/details.aspx?id=10910

Tags:
November 29th, 2011

MS Office – Executable File Versions

It can sometimes be necessary to determine the version of the program you are working with in VBA and I have been unable to find a comprehensive listing.  Microsoft themselves have scattered this information over numerous pages?!  Here is what I have compiled myself thus far (Office 2000 through Office 2010 SP1).

 

Application Name Executable File 2000 2000 SP1 2000 SP2 2000 SP3 2002 2002 SP1 2002 SP2 2002 SP3 2003 2003 SP1 2003 SP2 2003 SP3 2007 2007 SP1 2007 SP2 2007 SP3 2010 2010 SP1
Microsoft Office mso.dll         10.0.2627.01 10.0.3520.0 10.0.4330.0 10.0.6626.0 11.0.5614.0 11.0.6361.0 11.0.7969.0 11.0.8173.0 12.0.4518.1014 12.0.6213.1000 12.0.6425.1000   14.0.4760.1000 14.0.6023.1000
Microsoft Access  msaccess.exe 9.0.2720 9.0.3821 9.0.4402 9.0.6926  10.0.2627.1 10.0.3409.0 10.0.4302.0 10.0.6501.0 11.0.5614.0 11.0.6361.0 11.0.7969.0 11.0.8173.0 12.0.4518.1014 12.0.6211.1000 12.0.6423.1000 12.0.6606.1000 14.0.4750.1000 14.0.6024.1000
Microsoft Binder       9.0.2702 9.0.2702                            
Microsoft Excel excel.exe 9.0.2720 9.0.3821 9.0.4402  9.0.6926 10.0.2614.0 10.0.3506.0 10.0.4302.0 10.0.6501.0 11.0.5612.0 11.0.6355.0 11.0.7969.0 11.0.8173.0 12.0.4518.1014 12.0.6214.1000 12.0.6425.1000 12.0.6611.1000 14.0.4756.1000 14.0.6024.1000
Microsoft FrontPage frontpg.exe 4.0.2.2720 4.0.2.3821 4.0.2.4426 4.0.2.6625 10.0.2623.0 10.0.3402.0 10.0.4128.0 10.0.6308.0 11.0.5516.0 11.0.6356.0 11.0.7969.0 11.0.8173.0            
Microsoft Groove groove.exe                         12.0.4518.1014 12.0.6211.1000 12.0.6421.1000 12.0.6600.1000 14.0.4761.1000 14.1.6009.1000
Microsoft InfoPath infopath.exe                 11.0.5531.0 11.0.6357.0 11.0.7969.0 11.0.8173.0 12.0.4518.1014 12.0.6214.1000 12.0.6413.1000 12.0.6606.1000 14.0.4763.1000 14.0.6009.1000
Microsoft OneNote onenote.exe                 11.0.5614.0 11.0.6360.0 11.0.7969.0 11.0.8173.0 12.0.4518.1014 12.0.6211.1000 12.0.6415.1000 12.0.6606.1000 14.0.4763.1000 14.0.6022.1000
Microsoft Outlook outlook.exe/outlib.dll 9.0.0.2711 9.0.0.3821 9.0.0.4527 9.0.0.6627 10.0.2627.1 10.0.3416.0 10.0.4024.0 10.0.6626.0 11.0.5510.0 11.0.6353.0 11.0.7969.0 11.0.8173.0 12.0.4518.1014 12.0.6212.1000 12.0.6423.1000 12.0.6607.1000 14.0.4760.1000 14.0.6025.1000
Microsoft PowerPoint powerpnt.exe 9.0.2716 9.0.3821 9.0.0.4527 9.0.6620 10.0.2623.0 10.0.3506.0 10.0.4205.0 10.0.6501.0 11.0.5529.0 11.0.6361.0 11.0.7969.0 11.0.8173.0 12.0.4518.1014 12.0.6211.1000 12.0.6425.1000 12.0.6600.1000 14.0.4754.1000 14.0.6026.1000
Microsoft Project winproj.exe         10.0.2915.0 10.0.8326.0     11.0.5614.0 11.0.6707.0 11.0.7969.0 11.0.8173.0 12.0.4518.1014 12.0.6211.1000 12.0.6423.1000   14.0.4751.1000 14.0.6023.1000
Microsoft Publisher mspub.exe         10.0.2621.0 10.0.3402.0 10.0.4016.0 10.0.6308.0 11.0.5525.0 11.0.6255.0 11.0.7969.0 11.0.8173.0 12.0.4518.1014 12.0.6211.1000 12.0.6423.1000 12.0.6606.1000 14.0.4750.1000 14.0.6026.1000
Microsoft SharePoint Designer spdesign.exe                         12.0.4518.1014 12.0.6211.1000 12.0.6423.1000   14.0.4750.1000  
Microsoft Visio vision.exe/vislib.dll         10.0.525 10.1.2514 10.2.5110   11.0.3216.5614 11.0.4301.6360 11.0.7969.0 11.0.8173.0 12.0.4518.1014 12.0.6211.1000 12.0.6423.1000   14.0.4756.1000 14.0.6022.1000
Microsoft Word winword.exe 9.0.2720 9.0.3821 9.0.4402  9.0.6926 10.0.2627.0 10.0.3416.0 10.0.4219.0 10.0.6612.0 11.0.5604.0 11.0.6359.0 11.0.7969.0 11.0.8173.0 12.0.4518.1014 12.0.6211.1000 12.0.6425.1000 12.0.6612.1000 14.0.4762.1000 14.0.6024.1000

You can also download a copy in csv format so you can import it into the program of your choice by clicking here.

Also, note that some of this information is impossible to find on any official website (but then again, why would I be writing such a post if it were!) so there could be mistakes.  This is based on what I could find online and what I managed to piece together by looking over various computers.  If you find mistakes, please use the contact form to send me an e-mail and I will make the necessary corrections promptly.

Here are a few of my references that I used to compile this list:
Office 2000
Office 2002 (Office XP)
Office 2003
Office 2007
General info on how to retrieve the Executable’s build number

October 4th, 2011

MS Access – AutoNumber Field

We tend to see numerous questions relating to MS Access Autonumbers. Specifically, regarding autonumber not following sequence, skipping sequence.

Regardless of how one might interpret what is written in the help files, AutoNumbers should never, ever, ever, be relied upon as a sequential number. Nor should they ever be used/displayed to the end-user. The simple fact of the matter is that AutoNumbers are merely unique identifiers for each record. Even when set to be incremental, the AutoNumber can be indexed even though no record was actually inserted into the table. This is not a bug, this is simply the way Access was developed.

So what does one do if they require a sequencial number to attribute to each record. The solution is actually very simple. Create a new field in your table and then you can used an equation such as =Dmax(…)+1 to generate the next number in your sequence. But at the end of the day, if you want a sequential number that will not jump sequence and can be faithfully relied upon, you have to create it yourself!

July 21st, 2011

MS Access – Tables – Where to Create Relationships? In the Front-End or Back-End?

Now here is a question I had myself many years ago and could never find a proper answer to! And yet it is such a basic element and such an important one at that!!!

So when one creates a split database (which they all should be), where do you create the tables relationships exactly? Do you create the MS Access table relationship within the Front-End or the Back-End?

The short answer is, in the Back-End. Here are a few explanation from a couple fellow MVPs taken from a recent forum question.

The relationships need to be established in the backend. In fact, you can build a diagram in the frontend but for the backend tables, the referential integrity will not be enforced if the relationships aren’t in the backend — Bob Larson, Access MVP

If you create relationships in the front end the only thing it achieves is that it determines the default joins types when you create a query in design view. To ensure data integrity through enforced relationships they must be created in the back end. So, the recent advice you were given is wrong. You can if you wish create them in the front end in addition to, but certainly not in place of, those in the back end. — Ken Sheridan

What is important to understand here is the fact that you should always create your table relationships in the Back-End of your database. That said, as Ken stated it can be useful to merely recreate them within the Front-End as well to simplify Query building, but then this then incurs extra overhead when the database is modified (Now you have to update the relationships in both locations). The other time when you might create MS Access table relationships within the Front-End of your database is because you have lookup table, reference tables in the Front-End. In such a case, obviously you can’t create the necessary table relationships in the Back-End since the tables don’t exists there. As such, you’d create the necessary relationships directly within the Front-End to ensure referential integrity.

April 30th, 2011

MS Access – JET SHOWPLAN

I came across an article about optimizing queries using a hidden JET tool call SHOWPLAN which basically generates a showplan.out file (which is merely a text file) which elaborates the method used by Access to execute the query. With this information it is possible to perform optimizations, determine which fields require indexing…

I’m not going to rewrite the article, if the subject interests you, then simply look at the source article.

That said, I did want to try and add a little more information for anyone trying to get this to work using Windows 7 (possibly Windows Vista – untested). To be able to use ShowPlan one must create a registry entry to enable it. In the original atricle, they indicate that the base registry key is found at:

\\HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\JET\4.0\Engines

this may be the case for Windows XP, but if you are using Windows 7 (and I suspect Vista as well) you will not find this key. Instead look for:

\\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Jet\4.0\Engines

March 13th, 2011

FMS Total Visual SourceBook Review

FMSTotal Visual SourceBook

What I wouldn’t have given to be aware of this add-in when I was starting out as a developer! Seriously, this add-in would have saved me hundreds, if not thousands, of hours searching online, posting to forums, to find out how to code what I needed to do. Beyond which, it provides the user with a standardized set of procedures, instead of trying to piece together countless routines found here and there as you search online.

Just yesterday, I needed a particular routine and instead of searching online, as I always have done until now, I opened the TVSB, performed a quick search, exported the appropriate code into my module and was back at work in a matter of 1-2 minutes, if that!

 

So what did I think of the TVSB?

Cons:

  • I wish it could be somehow directly integrated within the VBE as done with certain other add-ins rather than a separate popup application. Have some type of integrated toolbar with a drop down category/procedures/… select the procedure and BAM there is. AND, I’m not saying it is hard to export the procedures from the SourceBook the way it is currently setup. That said, even though it would be nice, I myself am not sure how it could be accomplished.
  • My other issue is that their code uses Early biding which I try to avoid normally as it can causes reference issues. So their code is a nice starting point, but I would convert most of the classes, procedures,… into late binding for my own purposes. Over the course of several years, I have learnt that Late Binding avoids reference issues and this outways (in my opinion) any performance benefits Early Binding presents. At the end of the day, each developer has their own opinion and experience with regards to this aspect of programming, so feel free to make up your mind on this aspect yourself. To learn a little bit more about the pros and cons of Early Binding vs. Late Binding take a look at Early vs. Late Binding
    from the Word MVP site, it is a short overview of the issue.

 

Pros:

  • Easy to install
  • Can be integrated to work in a team environment (untested)
  • Easy to navigate and work with
  • It is very intuitive
  • Came with a user manual! Just this to me put this application above most others!!! Although, in this case, a manual is not necessary.
  • The code itself, is well categorized so you can find things quite easily just by noising around.
  • Effective search tool enable one to quickly search through the repository.
  • Extendable. You can add your own code (procedures, modules, …) to the repository so you can build upon what is already there.
  • Good export utility (export directly into your module, to a file, …)
  • Customizable – You can configure the Error Handler and other elements to suit your programming methodologies.

Put simply, the FMS Total Visual SourceBook (TVSB) is a simple to use, powerful work tool that can easily accelerate the development process of any developer and give you a leg up on your competition.

January 17th, 2011

MS Access – VBA – The Save Operation Failed

I was recently working on a database of mine which has been in production for over 4 years now and all of a sudden it started giving me the error: “The Save Operation Failed”. Nothing like a nice obscur error message from the VBA/VBE!!!

I tried the normal approaches: Compact and repair, Decompile/Recompile, … None worked for me.

I took a look at Microsoft’s Knowledge Base and found an article, ACC97: Error “The Save operation failed” When Saving a Module, for Access 97 (as a lot of the information can be used in furture version, I read it over). Sadly, the article is pretty much useless.

In the end, the solution, for me, was to start a new database and import all of the database objects (File -> Get External Data -> Import) from the database giving me the error message. Setup the startup properties… and everything was in working order again!

I hope this helps someone else in the same perdicament!

January 6th, 2011

MS Access – VBE – Plug-Ins, Add-Ons, Etc

One thing any good worker will tell you is that you must have the right tools to do the job. Computer programming, MS Access database development, is no exception to this rule! I thought I’d list a few add-ins, plug-ins, etc. that I have come across, or heard of. This is an unbiased listing and I have no link to any of the vendors, nor have I even used all of them. I am simply trying to regroup them to help you find them, and you can judge their usefullness on your own. In a future post, I will examine the 2 or 3 that I use myself and find very useful.

Free Ones
MZ-Tools
Smart Indenter
V-Tools

Ones you have to pay for
Find and Replace (30 day evaluation then you have to register/pay)
FMS Inc. Tools — FMS offers a multitude of various tools worth reviewing, including: Total Visual Source Book and Total Access Admin

 

A Few More Untested Add-ins (Update 2011-Mar-09)

Various utilies by Bill Mosca (Access MVP)
ACCESS Dependency Checker
http://www.4tops.com/query_tree.htm
http://www.4tops.com/ms_access_vba.htm
Compare Em – Compare 2 database to identify the differences and generate the necessary code to make the updates.

October 29th, 2010

MS Access – Running Access on a MAC

Ever needed to run an MS Access database on a MAC? It can be done.

One solution, is to install Parallels Desktop on the computer. This enables one to run Windows software directly on a MAC. Once it is installed, you then would install the OS of your choice and the MS Access. So you need valid OS license and a valid MS Access license or use the free run-time version.

That said, at $80 for parallels and then another $200+ to get a copy of windows this starts to become an expensive endeavour if it is only to use MS Access! Never the less, it is a viable option for those looking for a solution to a problem.

October 28th, 2010

MS Access – Running Access on Linux/Ubuntu

Have you ever had a client throw you the nice curveball of wanting to run an MS Access database on a Linux OS? Well, there is a workable solution.

You can install Wine on most Linux distributions. You can check out their website at http://www.winehq.org/download. You can also chack out their brief page regarding MS Access at http://appdb.winehq.org/objectManager.php?sClass=application&iId=12

Overall, this seems to be a very good option for older versions, and slightly less reliable for the newer version (2007) with no data regarding 2010 compatibility. Depending on you needs, this is definitely worth checking out and the price is right, it’s free (you have to love open-source)!

October 18th, 2010

MS Access – Make Tables Read-Only

Now here is an interesting question!

My first reaction to such a question is why? Since proper database design implicitly prohibits the users from ever directly accessing the database tables, this should never truly be an issue for any developer. But then again, as I have learnt of the course of the years, there are so many exceptional cases…

 

A Few Solutions to Make a Table Read-Only

  • If you are using an mdb format, then you could simply implement User-Level Security (ULS) and simply apply the proper permissions to make your desired tables read-only to your users.
  • A more general solution, and one that would also work in all versions of MS Access, would be to migrate the tables you wish to be in Read-Only mode, into a second back-end file and then set the file attributes to Read-Only. Then link the tables to your front-end.

October 12th, 2010

MS Access – Trig Functions

Have you ever needed to use trig functions in your database?

You may have noticed that although MS Access does offer basic trig functions:

  • Sin
  • Cos
  • Tan
  • Arctangent (atn)

it does not offer any of the advance, ‘Derived Math Functions’, such as:

  • Secant
  • Cosecant
  • Cotangent
  • Inverse Sine
  • Hyperbolic Sine
  • Inverse Hyperbolic Sine

As a developer you have one of two options:

  • Create, or find, a function to replicate these functions
  • Utilize Excel’s trig functions from within you database

 

Create, or find, a function to replicate these functions

If you simply lookup the term ‘Derived Math Functions’ in the VBE’s help file you will find all the necessary information to build your own custom functions. That said, why not simply benefit from the fact that others before you have already done this work for you and simply perform a quick Google search to locate and existing module with these functions. For instance:

 

Utilize Excel’s trig functions from within you database

If you know that the database will be utilized on a computer that also has Excel installed on it, why not simply use it’s powerful library of trig function! Nothing could be easier to do. Simply use a procedure such as the one presented below

'---------------------------------------------------------------------------------------
' Procedure : Atanh
' Author    : CARDA Consultants Inc.
' Website   : http://www.cardaconsultants.com
' Purpose   : Calculate the Inverse Hyperbolic Tangent by using Excel's built-in
'             function
' 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).
'
' Input Variables:
' ~~~~~~~~~~~~~~~~
' x                 Value in Rads
'
' Usage Example:
' ~~~~~~~~~~~~~~~~
' Atanh(-0.9)       Gives -1.4722...
' Atanh(0)          Gives 0
'---------------------------------------------------------------------------------------
Function Atanh(x As Double) As Double
'This procedure requires a reference be set to the Microsoft Excel xx.x Library
On Error GoTo Error_Handler
    Dim oXls    As Excel.Application
 
    Set oXls = New Excel.Application
    Atanh = oXls.WorksheetFunction.Atanh(x)
 
Error_Handler_Exit:
    On Error Resume Next
    oXls.Quit
    Set oXls = Nothing
    Exit Function
 
Error_Handler:
    MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
           "Error Number: " & Err.Number & vbCrLf & _
           "Error Source: YourModuleName/ListDbTables" & vbCrLf & _
           "Error Description: " & Err.Description, vbCritical, _
           "An Error has Occured!"
    Resume Error_Handler_Exit
End Function

September 15th, 2010

Launch/Open an MS Access Database Using a VBScript – Part 2

In my previous post launch-open-an-ms-access-database-using-a-vbscript I went over the basic concept of using a VBScript to launch a database.

In this post I would like to demonstrate the true power of VBScript for this type of application.

Say, you are a developer within a structured company network environment and you want to standardize the front-end setup on your users computers without having to sit down at each of their computers, one by one. Well, VBScript to the rescue!

The script below may seem scary, but really isn’t. It start by determining the user’s My Documents location. This is where I have chosen to place the Front-End application of the database. You could always alter this aspect, but it has served me very well in numerous routines. Once it has determine the location it determines the location of the VBScript itself (which will be installed with the Master copy of the Front-end). As such, it copies the Master copy to the user’s My Documents. Then it determines the location of the msaccess.exe required to launch the database and then finally launches it!

Once again, I do hope this helps someone out there as I found it hard to come across this information several years ago when I needed it.

'*******************************************************************************
'Date:		2008-05-27
'Author:	Daniel Pineault / CARDA Consultants Inc.
'Purpose:	This script should be located on a network share in the same
'		directory as the Front-End which it will automatically copy
'		to each user's MyDoc\Subfolder\ and then launch
'		Give your users a link to this script and it will do the rest
'Copyright:	You are free to use the following code as you please so long as
'		this header remains unaltered.
'Revision:	2008-05-27   Initial Release
'*******************************************************************************

	Const MY_DOCUMENTS = &H5&
	Const PROGRAM_FILES = &H26&
 
	Dim objShell
	Dim objFolder
	Dim objFolderItem
	Dim objNetwork
	Dim objFSO
	Dim objShellDb
	Dim DelFoldr
	Dim sMyDocPath
	Dim sProgPath
	Dim sVBSPath
	Dim sAccPath
	Dim sFrontEnd
	Dim sFolder
	Dim sSec
	Dim sUser
	Dim sPath
	Dim sComTxt
 
 
	'Specify the Fullpath and filename of the database to launch
	sFrontEnd = "test.mdb"	'Database name to open
	sFolder = "Databases"		'MyDoc subfolder where the
						'front-end will be copied to
	'If your database is secured by an mdw file specify it below, otherwise
	'leave its value blank
	sSec = "Security.mdw"
 
 
'Determine the location/path of the user's MyDocuments folder
'*******************************************************************************
	Set objShell = CreateObject("Shell.Application")
	Set objFolder = objShell.Namespace(MY_DOCUMENTS)
	Set objFolderItem = objFolder.Self
	sMyDocPath = objFolderItem.Path		'My Documents path
	sPath = sMyDocPath & "\" & sFolder & "\"'Path to front-end
	Set objFolder = objShell.Namespace(PROGRAM_FILES)
	Set objFolderItem = objFolder.Self
	sProgPath = objFolderItem.Path		'Program Files Path

'Determine path of this VBScript
'*******************************************************************************
	sVBSPath = Left(WScript.ScriptFullName,(Len(WScript.ScriptFullName) _
		     - (Len(WScript.ScriptName) + 1)))
 
	'Ensure lastest version of front-end is installed
	Set objNetwork = CreateObject("Wscript.Network")
	sUser = objNetwork.UserName			'User's network username
	Set objFSO = CreateObject("Scripting.FileSystemObject")
 
'Copy a network version of the Front-end to the MyDocs/SubFolder
'*******************************************************************************
	If objFSO.FileExists(sPath & sFrontEnd) Then
 
	Else
  		If objFSO.FolderExists(sPath) then
    			'Delete folder to perform cleanup of old version(s)
    			Set DelFoldr = objFSO.GetFolder(sPath)
    			DelFoldr.Delete
  		End if
  		'Create folder and then copy required file(s)
  		Set objFolderCreate = objFSO.CreateFolder(sPath)
  		objFSO.CopyFile sVBSPath & "\" & sFrontEnd, sPath & _
                  		sFrontEnd, OverWriteExisting
	End if
 
'Determine the location of the MS Access executable
'*******************************************************************************
	Set objShellDb = CreateObject("WScript.Shell")
	'Determine in which folder the Access executable is located
	If objFSO.FileExists(sProgPath &_
                     	     "\Microsoft Office\OFFICE11\msaccess.exe") Then
		sAccPath = sProgPath & "\Microsoft Office\OFFICE11"
	Elseif objFSO.FileExists(sProgPath &_
                                 "\Microsoft Office\OFFICE10\msaccess.exe") Then
  		sAccPath = sProgPath & "\Microsoft Office\OFFICE10"
	Elseif objFSO.FileExists(sProgPath &_
                                 "\Microsoft Office\OFFICE\msaccess.exe") Then
  		sAccPath = sProgPath & "\Microsoft Office\OFFICE"
	End if
 
 
'Launch database
'*******************************************************************************
	'Build the command to launch the database
	sComTxt = chr(34) & sAccPath & "\" & "msaccess.exe" & chr(34) &_
		  " " & chr(34) & sPath & sFrontEnd & chr(34)
	if isNull(sSec)=False AND sSec<>"" Then
		sComTxt = sComTxt & " /wrkgrp " & chr(34) & sVBSPath &_
			  "\" & sSec & chr(34)
		if isNull(sUser)=False AND sUser<>"" Then
			sComTxt = sComTxt & " /user " & sUser
		End if
	End if
 
	objShellDb.Run sComTxt 'Launch the database

Tags:
September 14th, 2010

Launch/Open an MS Access Database Using a VBScript

Have you ever tried to make a shortcut to launch/open an MS Access database and had an error returned because the Target string was too long? Or do you simply need more control/flexibility from your launching routine. In that case, a VBScript is the ideal way to go. Below is the most basic format that the VBScript can take. Simply alter the Script Variables, Save and execute!

I have made the following as flexible as possible so it can open simple database files, as well as security enabled database. It is simply a question of assigning values to the Script Variables or not.

I truly hope this helps you out!

'*******************************************************************************
'Date:		2008-05-27
'Author:	Daniel Pineault / CARDA Consultants Inc.
'		http://www.cardaconsultants.com
'Copyright:	You are free to use the following code as you please so long as
'		this header remains unaltered.
'Purpose:	Launch the specified access database
'Revision:	2008-05-27   Initial Release
'*******************************************************************************

	Dim sAcc
	Dim sFrontEnd
	Dim sSec
	Dim sUser
	Dim objShellDb
	Dim sComTxt
 
'Script Configuration Variable
'*******************************************************************************
	'Specify the Fullpath and filename of the msaccess executable
	sAcc = "C:\Program Files\Microsoft Office\OFFICE11\msaccess.exe"
	'Specify the Fullpath and filename of the database to launch
	sFrontEnd = "D:\Main\My Documents\TestDb.mdb"
	'If your database is secured by an mdw file specify it below, otherwise
	'leave its value blank
	sSec = "C:\Databases\Security.mdw"
	'If your database is secured by an mdw file and you want to specify the
	'username to use specify it below, otherwise leave its value blank
	sUser = ""
 
 
'*******************************************************************************
'*******************************************************************************
'You should not need to edit anything below this point
'*******************************************************************************
'*******************************************************************************

 
'Launch database
'*******************************************************************************
	Set objShellDb = CreateObject("WScript.Shell")
	'Build the command to launch the database
	sComTxt = chr(34) & sAcc & chr(34) &_
		  " " & chr(34) & sFrontEnd & chr(34) 
	if isNull(sSec)=False AND sSec<>"" Then
		sComTxt = sComTxt & " /wrkgrp " & chr(34) & sSec & chr(34)
	End if
	if isNull(sUser)=False AND sUser<>"" Then
		sComTxt = sComTxt & " /user " & sUser
	End if
	objShellDb.Run sComTxt 'Launch the database

Tags:
August 24th, 2010

MS Access – Splitting and Deploying Your Database

Splitting and Deploying Your Database

So you’ve developed a database and now you are finally ready to deploy it to your users! There are a couple things to consider to simplify your life as much as possible.

 

Split Your Database

Split? Yes, if you have not done so, and you are setting up a network or multi-user database, it is time to split your database. This is a simple process by which the tables are placed into one database (called the Back-End) and the remaining database objects (queries, form, report, code) are placed into another database (called the Front-End).

The Back-End is then placed on the office server and a copy of the Front-End is given to each user and setup on their PC. DO NOT allow your users to all connect using the same Front-End file, they should each have their own copy on their machine.

 

Why Split your Database

There are numerous reasons/advantages to splitting your database, such as:

  1. Performance – Since the Front-End is located on each user PC, it can have significant benefits in overall performance.
  2. Reduced Network Traffic – Since the Front-End is located on each user PC there is that much less data to transfer back and forth over the network.
  3. Maintenance/Updating – Splitting the database simplifies the process of performing updates. By creating update scripts, you can in effect simply replace the front-end and automatically upload it to your users while never having to take the database offline.
  4. Reduces Corruption – It has been stated that splitting your database can reduce data corruption.
  5. Multi-User – Splitting your database permits multiple-user simultaneous usage of your database.

 

How-to Split Your Db (Access 2000-2003)

Tools->database utilities->Database Splitter

 

How -to Split Your Db (Access 2007)

Database Tools -> Move Data -> Access Database

 

Database Splitting References

Split your Access database into data and application
Splitting a access database, or how to run ms-access in a multi-user mode
Splitting Microsoft Access Databases to Improve Performance and Simplify Maintainability

Tags:
August 24th, 2010

MS Access – Multiple Criteria DLookup

A common question in many a newsgroup/forum is how can I perform a DLookup with more than one criteria? Well, the fact of the matter is that the Criteria permits you to specify as many criterion as you please.

For instance, lets say we have a contact table named ‘tbl_contacts’ and we want to retrieve the Telephone Number (field TelNo) for Daniel (Field FirstName) Pineault (field LastName), then the code would look something like:

DLookup("[TelNo]", "tbl_contacts", "[FirstName]='Daniel' AND [LastName]='Pineault'")

Now let’s push this example a little further. Let’s assume instead of wanting to hard code the individual’s name, we want to pull the value from form controls. So let assume we have a form name ‘frm_contacts’ with controls named ‘txt_FirstName’ and ‘txt_LastName’, in that case the code would look something like:

DLookup("[TelNo]", "tbl_contacts", "[FirstName]='" & Forms![frm_contacts].Form.[txt_FirstName] & "' AND [LastName]='" & Forms![frm_contacts].Form.[txt_LastName] & "'")

Special Note

One important thing to properly grasp when building a criteria is how and if they need to be surrounded by any special characters.

  • Date values need to be surrounded by #Your Date Value#
    • “[DateField]=#10/17/2009#”
  • Text values need to be surrounded by ‘Your Text Value’
    • “[TextField]=’Daniel’”
  • Numeric values do not need to be surrounded by anything
    • “[NumericField]=200″
June 12th, 2010

MS Access – Listing of Database Objects

It can be useful to have a listing of all the objects in the database. For instance, a listing of all the table or queries… This can easily be achieved using a query which uses as its source a hidden system table named ‘MSysObjects’. The basic query SQL statment is as follows:

SELECT MsysObjects.Name AS [List OF TABLES]
FROM MsysObjects
WHERE (((MsysObjects.Name) NOT LIKE "~*" AND (MsysObjects.Name) NOT LIKE "MSys*") AND ((MsysObjects.TYPE)=1)) ORDER BY MsysObjects.Name;

You need only change the value of the (MsysObjects.Type)=1 part of the query expression to change what listing is returned. Below are the various values that can be used to return the various objects available in Access:

Object Type Value
Tables (Local) 1
Tables (Linked using ODBC) 4
Tables (Linked) 6
Queries 5
Forms -32768
Reports -32764
Macros -32766
Modules -32761
June 7th, 2010

Documenting Your Database, Creating a Database Help File

Creating support documentation:

 

There a couple options for providing support documentation for a database that you have developed:

  1. External documentation (Word document, HTML file,…)
  2. Help file and associated to various areas throughout your database
  3. Creating an Access Report within your database

Developing support documentation for your database is a enormous subject to cover and there are entire sites devoted to this exact subject. Below are a collection of what I consider to be the best of these sites:

Help Technology Centre – HTML Help with MS Access
TonyToews – Microsoft Access Help System Tips
HTML Help from Helpware.net
Shelpm help file software (free – very easy to learn and use!!!)
TechNet Information (Microsoft)
HTML Help Information (Microsoft)
Knowledge Base Information (Microsoft)
More Help Information from Microsoft

June 7th, 2010

WHY MS ACCESS

The following was taken from a discussion group and I believe is a very good explanation of the subject.

“Access is really an application development environment. It includes not one but *two* database engines: JET, the database engine in .mdb files, and (with the newer versions) MSDE, which is simply SQL/Server.

An Access application can link to any ODBC compatible database server – Access/JET databases, SQL/Server, MySQL, Oracle, DB/2, Visual FoxPro, dBase, take your pick (they all have their own advantages and disadvantages). SQL/Server, MySQL, and Oracle are all very capable database engines – but, by themselves, they don’t have tools for building user interfaces (forms and reports). You can use Visual Basic, C++, etc. to do so, or pay for expensive tools to frontend them- but Access is inexpensive and has a very capable form and report design feature.” – John W. Vinson [MVP]

“Microsoft Access is an “all-in-one” tool, whereas the other database engines require additional, specialized skills to make the “complete” package. Access provides easy access to the database engine (Jet for Access 2003 and earlier, ACE for Access 2007) for data storage and data integrity. Access also provides fairly easy connectivity to other database engines for data storage, data integrity and security. Access provides automated tools (wizards) to build the presentation layer, or “front end” (data entry forms, reports for data displays, custom coding in modules, et cetera). An expert in Access can be expected to know how to use (and can teach you how to use) all of these tools in Access.

The other database engines may or may not provide similar tools besides the data storage feature. MySQL provides only data storage. It doesn’t have tools to build the front end. Oracle provides many additional reporting tools and presentation tools in addition to data storage, but these are so highly specialized that it usually takes a minimum of two or three Oracle professionals to build an application and manage the data. Microsoft SQL Server now has additional reporting tools and custom coding (T-SQL, CLR, and GUI managers) available, but again, these are so highly specialized that it usually takes a minimum of two or three SQL Server professionals to build an application and manage the data.

Access can handle additional complexity as your skills grow, and then allow you to migrate the back end to an even more complex database engine without having to start over from scratch when your organization’s needs increase and your workforce expands.

Managing the other database engines compared to managing Jet is more complex by an order of magnitude. Oracle is even more complex than the others, so increase the complexity by another order of magnitude. Unless you plan to get formal training, don’t expect to “jump in” and just “wing it” with Oracle. With the other database engines you can “jump in” without formal training, but expect to make so many mistakes that you shouldn’t plan to use real data until you have at least six months to two years of experience, so formal training is also a good idea.” – Gunny

“Depending on the version, bells, and whistles, Oracle is about $40,000 for one license. So if you don’t already have Oracle, there’s a steep cost there.

One person who can do both DBA and Developer duties in Oracle will be very expensive as extensive skills are needed. Add to that the extra time it takes to get an Oracle app up and running.

I’m an Oracle DBA by day and develop Access apps by night. All things being equal, I probably can bring in an Access database for about one-fifth the price of a similar Oracle app in half the time. Of course the Oracle app can easily handle hundreds, not dozens, of users plus Oracle databases don’t have a corruption problem. If one does corrupt, there’s multiple ways to recover the data or not even let the user’s know that there was a problem.” – Jerry Whittle

June 7th, 2010

MS Access Database Templates

A great way to learn how-to develop your own database is to look at pre-made databases.  As such, below is a listing of database templates from various sources.

Microsoft

http://office.microsoft.com/en-us/templates/CT101527321033.aspx?av=ZAC

If you know of other, non-commercial template (ie: free with no strings attached) please let me know so I can add them to the list.

June 7th, 2010

MS Access Books

Mastering Microsoft Access 2000 Visually published by IDG Books Worldwide – Great introductory book for new Access Users who wants to get up to speed rapidly with the basics of MS Access.

Access 97 Developer’s Handbook by Paul Litwin, Ken Getz & Mike Gilbert and published by SYBEX – Great Book for Acccess programmer’s (There are newer versions obviously!)

June 7th, 2010

MS Access Add-ins and Programming Tools

MZ-Tools - Great add-in for the VBA Editor (and best of all it is FREE!)
VBScroll – Get your mouse wheel functional in the VBE window
FreeWheel – Another free utility that enabled your scroll button in the VBE window (Google it to find a download site)

June 7th, 2010

MS Access Forums and Discussion Groups

MS Access Forums and Discussion Groups

Post your specific questions and get them answered by the discussion group in real-time. Below is a list of those MS Access discussion groups which I have found to be very useful, or that have been recommended by others.

Microsoft’s Forum Groups (covers all MS products – Being closed by MS as of June 1st, 2010)
http://social.answers.microsoft.com/Forums/en-US/addbuz
http://social.msdn.microsoft.com/Forums/en-US/accessdev/threads
http://www.UtterAccess.com
http://www.access-programmers.co.uk/forums/
http://www.accessforums.net/
http://www.accessmonster.com/Uwe/ForumList.aspx
http://stackoverflow.com/
http://tech.groups.yahoo.com/group/MS_Access_Professionals/

 

MS Access NewGroups

If you prefer to use NewsReaders, then below are a couple Newsgroups that cover MS Access.

comp.databases.ms-access
microsoft.public.access.*

June 7th, 2010

MS Access Websites

Below is a brief listing of some of the useful websites that I have found navigating the web in search of answer to my own Access questions/problems. Most of these site are full of free information, tutorials, tips and tricks, samples, … . All you need is some time to go looking.

The MVPS website Microsoft Most Valuable Professional’s website (Explanation, Code, etc.. – great resource)
Google Groups Here you can search through postings previously made… you probably aren’t the first person to ask the question so chances are that if you look it up you’ll find an answer waiting for you.
Microsoft Templates Microsoft has provided some templates. These are great starting points to which you can make customizations. These sample databases are also great learning tools to introduce beginners to various database concepts by learning by exmple.
Roger’s Access Library Lots of sample databases illustrating various database technics and principles
FunctionX Access Tutorials Tutorials covering most every basic aspect of using MS Access
Tony Toews Website “Tony’s Microsoft Access tips, hints and links including Email FAQ and Access based accounting systems. One of the oldest Microsoft Access websites.”
Stephen Lebans’ Website On this website you will find numerous APIs and other samples to do what you thought was impossible with access.
Allen Browne’s Website This website has numerous tips and solutions to common problems (from basic to very advanced)
Doug Steele’s Website This website has numerous links to other great Access sources of information. Also, make sure you check out his Smart Access article archive!
Albert D. Kallal’s Website An MS Access MVP’s website full of useful information, tips and examples.
Jeff Conrad’s resources page A very extensive listing of valuable Access resources (newsgroups, books, websites, tutorials, add-ins,…).
A free tutorial written by Crystal (MS Access MVP): A great starting point if you want to start learning the basics about databases and MS Access.
BTAB Development Here you will find a vast variety of information, code sample, links, tutorials, sample database, etc.
MS How-To Articles Provided by www.kayodeok.btinternet.co.uk A vary comprehensive list of MS How-To articles that cover a wide range of common database concepts and problems. This website also has indexes of How-To articles for all the other common MS software programs.
MS Access – MSDN Blog This blog is a veritable treasure chest of information covering a multitude of versions… Enjoy perusing the vast database of information.