February 19, 2009

Create blank lines in a printed Word form the easy way

  • Date: November 18th, 2008
  • Author: Mary Ann Richardson

Creating printed forms can be a hassle if you can’t get those blank lines to cooperate. Learn one of the easiest and most versatile ways to set up your form: using underlined tabs.


Word users often create printed fill-in forms that include underlined blanks spaces for writing in form data. While you can press Shift + – (hyphen) repeatedly to create these daily cialis dose underlined spaces, it’s difficult to line up the lines. Leader tabs make it easier to create even lines, as well as saving keystrokes, but you’re limited to four underline styles.

Using the Underline button to underline tab characters gives you all the advantages of leader tabs with a wider choice of underline styles. For example, say you have used tabs to lay out your form, as shown in Figure A.

Figure A

tabbed form

To create the lines, just follow these steps.

  1. Click the Show/Hide button on the Standard toolbar so that you can see tab marks in your document. In Word 2007, click Show/Hide on the Home tab in the Paragraph group.
  1. Select the first tab mark you want to underline, then hold down the Ctrl key while you select each of other tab marks (Figure B).

Figure B

tab selection

  1. Go to Format | Font, choose the thick underline style from the Underline drop-down list, and click OK. In Word 2007, go to the Home tab, click the Underline button arrow in the Font group, and select a style from the Underline style list (Figure C).

Figure C

underline format

All lines will be printed, as shown in Figure D.

Figure D

underlines

Permalink • Print • Comment

How do I … create the autorun.inf file for my CDs and DVDs?

  • Date: November 11th, 2008
  • Author: Mark Kaelin

Contrary to what you may have heard from the RIAA, burning a CD-R or CD-RW is not an activity restricted only to music pirates. In many business situations, the burned CD is the best way to distribute information to a target audience. For communications involving PowerPoint presentations, HTML, PDF forms, Flash animations, or a number of other applications, the portable and durable CD has become a common delivery method.

The compact disk drive auto play feature, common to most operating systems, is a good way to simplify user experience. Auto play is controlled by a simple text-only file called autorun.inf. While there are dozens of software utilities available that will help you create the file, all you really need is a text editor and some basic knowledge.

This How do I… is based on Microsoft Windows, but other operating systems will read the autorun.inf file in a similar fashion.

Solution One: Create autorun.inf

The basic configuration of the autorun.inf states the program to run when the CD is inserted in the drive and the icon to display when the disk is viewed by Windows Explorer or other directory listing software. The text-only file, which resides in the root directory of the CD, should follow this pattern:

[autorun]
open=myprogram.exe
icon=myicon.ico

The icon file should also reside in the root directory of the CD.

Variations

Often the program you want to run will not be located in the root directory of the CD. If that is the case you must include the path:

[autorun]
open=folder1\folder1A\myfile.exe
icon=myicon.ico

Sometimes you may need to pass an argument to the program to be auto played:

[autorun]
open=myprogram.exe /argument
icon=myicon.ico

Not a program

Sending customers, salespeople, investors, and employees presentations, PDF files, and HTML documents requires a slight variation to the basic autorun.inf file and the addition of a DOS batch file to the CD root directory. The autorun.inf file opens a batch file, which then opens the file using the default program designated for that file type. For example:

[autorun]
open=autorun.bat index.htm
icon=myicon.ico

And the autorun.bat file reads:

echo off
@start %1 %2 %3 %4 %5 %6 %7 %8 %9
@exit

There is a variation on this idea that takes advantage of the ShellExecute command:

[autorun]
ShellExecute=index.htm
cialis without prescription /> icon=training.ico

Using the autorun.inf file to auto play your burned CDs will prevent another headache for your users and increase the likelihood of reaching your target audience. And because it is a simple text file, it can be created with a text editor and your normal disk-burning software.

Solution Two: Create autorun.inf

While creating your autorun.inf file according to Solution One will work for most of your users, it will fail for a small percentage who have issues with the autorun function in their particular installation of Windows. The batch file in the first solution makes no allowances for errors and will merely fail when an error is encountered.

This is where a shell utility can save the day, because these third-party applications contain routines for handling common errors and will complete the autorun process even if an error is encountered. For this example, we’ll use autorun.exe, which can be downloaded from Tarma Software Research. Tarma has made autorun.exe freely available for both personal and commercial use, and there are no requirements for copyright notices, etc.

To use autorun.exe, you make a simple modification to the autorun.inf file by replacing autorun.bat with the .exe file. The basic autorun.inf under this scenario would look like this:

[autorun]
open=autorun.exe index.htm
icon=myicon.ico

The only other requirement is that a copy of the 8KB autorun.exe file be included in the root directory of each burned CD. This application also contains several options and supports an extended autorun.inf structure that provides more flexibility in how you design your CD package.

Permalink • Print • Comment

10 Linux desktops you shouldn’t overlook

  • Date: November 5th, 2008
  • Author: Jack Wallen

Even if you’re happy with the Linux desktop you currently use, you might want to check out some alternatives to see what you could be missing. Jack Wallen highlights 10 of the best desktops and explains what makes them stand out.


If you know Linux, you know there are tons of options on every level. To some, this might seem overwhelming at first. To others, it’s all about possibility. The desktop is certainly not without options. In fact, the Linux desktop might very well be the area where there are the most options. But for a lot of users, desktop selection doesn’t usually go beyond KDE or GNOME. With this article, I hope to help the average Linux user get beyond the standard fare.

Note: This information is also available as a PDF download.

#1: Enlightenment

I have to confess I put this at the top of the list because it is my favorite Linux desktop. This desktop is all about being full of eye candy, while at the same time being lightweight and fast. Enlightenment was created by Carston Haitzler (Raster) in 1996. He created Enlightenment to be a lightweight window manager that didn’t lack style. He succeeded (and then some).

Currently, Enlightenment is enjoying two releases: E16 and DR17. E16 is the current stable release and DR17 is the development release. The two releases are very different from one another. DR16 takes a far more minimalist approach to the desktop than DR17 does. Without Panels and Icons, the DR16 desktop is made up of three mouse menus (one for each button), an Iconbox (where windows are Iconified — or minimized), a Pager (to switch between desktops), and  the Dragbar (which allows you to have desktops layered on top of one another.)

The DR17 release removes the Iconbox and the Pager and adds Shelves, which are Panels that house application launchers, pagers, clocks, etc. Even with the creation of a more standard desktop, DR17 retains its uniqueness as well as its speed. If you’re looking to give DR16 a try, you can install it via the standard Linux installation methods. Your best bet for DR17 is to give the gOS Rocket or the EliveCD distributions a try. And you should… it’s that cool.

#2: AfterStep

This is another of my favorite Linux desktops. Or at least it was back in early days of Linux. This desktop attracted me because it was one of the first (back around 1998) to use transparency. AfterStep was actually a fork of FVWM rebuilt to resemble the NeXTSTEP desktop. Like FVWM, AfterStep is light, quick, and can be as minimalist (or not) as you like. The main features of AfterStep are a mouse menu, Pager, Wharf (a dock-like applet), and the Winlist (a panel showing active applications). AfterStep is highly configurable via flat text files (so configuration requires getting to know the layout of configuration files.)

Currently AfterStep is enjoying the 2.2.8 release and is headed up by Sasha Vasko. One of the best aspects of AfterStep is the ability to granularly configure the look and feel. From timing of auto-raising windows to placement of titlebars (titlebars can be placed along a horizontal or vertical plane), AfterStep can be configured to a much higher level than most other window managers. You can install AfterStep your usual way. For example, in Mandriva, run the command urpmi AfterStep to install.

#3: Fluxbox

Fluxbox is probably one of the lightest of the lightweight window managers for Linux. It’s lightening fast and incredibly stable. Fluxbox shines in bringing new life to old hardware. And Fluxbox is a gift for those who prefer a minimalist approach to the desktop. Fluxbox is a fork of the Blackbox window manager and was created out of a need to add more features to Blackbox.

The Fluxbox desktop contains a mouse menu, a toolbar, and the Slit. The Slit is a small dock where self-contained applets reside. All basic configurations are handled via flat text configuration files. This manual configuration includes everything from the theme to the menu. To give you an idea of the size of the Fluxbox window manager, the rpm installation file is 1,196 KB. To put this into perspective, the KDE 4 install base is 644.2 MB.

Installing Fluxbox is simple. You can either search for Fluxbox in your graphical installation application (such as Synaptic or Yumex) or you can install via command line (for example: urpmi fluxbox in Mandriva.) If you’re not into installing on your own, you can try the Ubuntu-based distribution, dedicated to Fluxbox, aptly named Fluxbuntu.

#4: XFCE

XFCE is quietly gaining ground on the Linux desktop with help from Zonbu, Mythbuntu, Slackware, and Gentoo. It’s another lightweight desktop that has a more traditional desktop approach, with icons, panels, start menus, and system trays. The XFCE desktop is far less configurable than many of its peers. XFCE was created to be very modular so you can install as much or as little as you want. XFCE is also separated into applications: XFWM (the XFCE window manager), Xfmedia (the XFCE media player), Orage (the XFCE calendaring application), and Thunar (the file management tool). It is interesting to note that Thunar is also now the file manager for Enlightenment DR17.

Installing XFCE is as simple as running urpmi xfce (in Mandriva) or opening up your graphical installation tool and searching for XFCE. If installing isn’t for you, you can download a number of distributions (Gentoo and Slackware for example.) The Mythbuntu Media Center distribution also relies on XFCE for a desktop.

#5: Compiz/Compiz Fusion

When you talk Compiz, you’re talking full-blown, eye-popping 3D desktop goodness. Compiz/Compiz Fusion (they are actually two different projects) is the one desktop to install when 1) you have the hardware for it and 2) you REALLY want to impress your friends and family. Compiz is the original 3D Linux desktop. Compiz Fusion is a merging of Compiz and the now-defunct Beryl Project. Both of these projects mimic some of the features of Apple’s cialis wiki OS X but take them to new places.

One of the most amazing features of Compiz and Compiz Fusion is the Cube. The Cube takes the flat Linux pager metaphor (the ability to have multiple desktops) and folds the desktops into a three dimensional cube. With a click of the middle mouse button the desktop cube zooms out and you can rotate the cube to the cube face you want to work on. Add to this the ability to make the cube (and everything on the desktop) translucent and you have a very impressive desktop.

Installing Compiz isn’t for the faint of heart. It requires a number of pieces to be put together, a video card that supports AIGLX, and some patience. But the time and effort are very much rewarded with one of the coolest desktops to date. If you don’t want to take the time to install, you can give the latest Mandriva or the latest OpenSuSE a go. With the right hardware, you should have a working 3D desktop upon installation.

#6: IceWM

The developers of IceWM are proud of the fact that this lightweight window manager shares absolutely no code with any other window manager (written completely in C++). IceWM can be made compliant with GNOME and can use Imlib for graphics support. IceWM is a fairly straightforward window manager with few frills. The desktop is a panel, a start menu, a system tray, and a pager, and that’s it. IceWM is as configurable as any standard window manager but doesn’t boast the eye candy that Enlightenment or AfterStep does. But unlike Enlightenment DR16, IceWM does have a graphical control center for configurations. IceWM is easily installed via the command like (for example yum install icewm in Fedora).

#7: Windowmaker

Another NeXT-based window manager, Windowmaker took what NeXT did right and did not add FVWM on top. Windowmaker is yet another lightweight, super-fast, highly stable Linux window manager. It takes a minimalist approach but does support most image formats, and it has sliding application menus that can be torn off and pinned. (You can break off a submenu and anchor it to the desktop, leaving it open until you manually close it.) All configuration changes happen in real time. Windowmaker does have a dock where applications can be launched, but it’s not the shadowed, animated dock found in OS X. Windowmaker can be installed via command line, as in urpmi windowmaker in Mandriva, or it can be found in the package administration tools, such as Synaptic.

#8: Metacity

For one brief period, Metacity was the window manager used in the GNOME desktop. Eventually, Metacity broke out on its own. Created by Havoc Pennington (of Red Hat), Metacity uses the GTK+2 toolkit. Pennington has described Metacity as “intentionally boring” even without a logo. Metacity does not include numerous features. Instead, it glaringly boasts “good defaults.” One would describe Metacity as a typical old school UNIX-like window manager. In fact, it’s clean to the point of being almost sterile. But that doesn’t mean it is without merit.

Metacity is lightweight and fast. It is also very much a *NIX window manager, in that it can be installed in nearly all *NIX operating systems. Many distributions (such as Mandriva) install Metacity by default. If Metacity is not installed by default, it can be installed by command (such as yum install metacity) or it can be found in the package administration tool.

#9: FVWM

FVWM was, at one time, the dominant window manager for the Linux operating system. In fact, my first exposure to Linux was the FVWM window manager, and I distinctly remember how like Windows 98 it was — though not as “clean.” FVWM has an interesting history. Robert Nation was the creator back in 1993. He was tired of the limitations of one of the only UNIX window managers, TWM, during his work with the DoD. Nation had already created the rxvt terminal emulator and decided to bundle FVWM with a release of rxvt. He handed FVWM over to another developer a year after its release.

The current version of FVWM is 2.4.20, but interestingly enough, Nation’s last release, 1.24r, will still compile and run on modern Linux distributions. FVWM has a number of derivatives, including AfterStep, Enlightenment, and Windowmaker. To install FVWM, just run apt-get install fvwm and accept the dependencies.

#10: CDE

CDE isn’t really a Linux desktop, but it deserves mention because it heavily influenced so many Linux desktops. CDE (Common Desktop Environment) was created by a collaboration between Sunsoft, HP, IBM, and USL (a collaboration called The Open Group) in 1993. This new desktop was based on HP Visual User Environment and was derived from the Motif Window Manager. For a long period, CDE was the standard UNIX desktop environment. But in 2001, it was briefly phased out in favor of GNOME (until GNOME’s instability caused the return of CDE).

CDE is a fairly standard desktop consisting of a panel and start menu. Its biggest downfall is its antiquated UNIX-like look, lack of anti-alias font support, and confusing configuration. CDE is primarily a Solaris desktop but will install on AIX and HP-UX.

A world of options

And there you have it: 10 Linux desktops (well, nine, really, plus one UNIX) that are all very different, very usable, and very available. You may be happy with your current desktop, but if you really are a fan of Linux, you owe it to yourself to try out one or more of the ones described here. There are plenty more Linux desktops; but these are the best alternatives. Give them a try and report back here to let us know your favorite.

Permalink • Print • Comment

E-mail multiple recipients without sharing e-mail addresses

  • Date: October 31st, 2008
  • Author: Susan Harkins

Don’t share e-mail addresses with the crowd. When sending e-mail to several people, use this trick to hide their addresses.


cialis wholesale

Sharing e-mail addresses is frowned upon, but that’s exactly what you do every time you send an e-mail to more than one person — whether you’re creating or forwarding the message. Everyone who receives the e-mail has the address for every other recipient.  Within the same organization, or an intimate group of friends and family, that’s okay. However, it isn’t okay if you’re sending a promotion or special discount to 100 clients who don’t know one another. Depending on the nature of your business, you could lose your job.One quick option is to send the e-mail to yourself and bbc all the recipients. Doing so hides all e-mail addresses but yours. The downside of this technique is that bcc messages tend to get snagged by spam filters. That means your mail might never reach some of the recipients.

A more dependable way to send an e-mail to a list of undisclosed recipients follows:

  1. Open the New button’s drop-down list and select Contact.
  2. Type Undisclosed recipients in the Full Name control. You don’t have to use that name; give your list a meaningful name that describes the recipients or the message’s intent.
  3. Enter your e-mail address in the E-mail field.
    october2008officeblog11fig1r.jpg
  4. Click Save And Close.
  5. Create a new e-mail message.
  6. Click the To button and choose Undisclosed recipients.
  7. Click To and highlight the necessary addresses.
  8. Click OK.
  9. Enter your message and click Send.

Remember that the name you give the undisclosed contact (step 2) will show in the e-mail’s header, so give that name a bit of creative and careful thought.

Permalink • Print • Comment

How to log errors in Microsoft Access

  • Date: October 31st, 2008
  • Author: Susan Harkins

If you Google “error logging in Microsoft Access,” you’ll find a number of complex solutions. But the process doesn’t have to be that difficult. Most of us need only a simple function to log specific information about the current error.


Despite all your best efforts, errors occur in every database. Most developers include adequate error-handling routines in their code, but that might not be enough. Knowing when an error occurs and how often it occurs can be important to resolving the issue and avoiding future errors. Access doesn’t track errors, but you can add that functionality to any database. All you need is a table and a little code.

Note: Our companion download includes a demonstration database and a several .bas module files you can import into any Access database. Don’t cut and paste the code directly from here into an Access module, as the article text contains formatting that will generate errors.

The easiest way

If you have just one database to maintain and you’re its only user, error logging isn’t a critical issue because you’re around when the error occurs. However, it’s difficult to display internal error information at the time of the error. It isn’t impossible, but even if your application displays it, you have to remember all of it. For that reason alone, adding a log can be helpful, especially during the testing stage.

The simplest way to log errors is to let each procedure’s error-handling routine do it. The error routine shown in Listing A (basErrorLog1.bas) inserts a record with error information into an existing table. To create the code, select Module in the Database window and then click New on the Database toolbar. Enter the code and save the module. (You can import the .bas file into any Access database, even an empty one.)

Listing A: ThrowError()

Function ThrowError()  On Error GoTo errHandler Dim strSQL As String Dim strDescription Err.Raise 6 Exit Function

errHandler:  strDescription = Chr(34) & Err.Description & Chr(34) strSQL = "INSERT INTO tblErrorLog (ErrDate, CompName, UsrName, " _ & " ErrNumber, ErrDescription, ErrModule)" _ & " VALUES(#" & Now() & "#, '" & Environ("computername") _ & "', '" & CurrentUser & "', " & Err.Number _ & ", " & strDescription & ", '" & VBE.ActiveCodePane.CodeModule & "')" DoCmd.SetWarnings False DoCmd.RunSQL strSQL DoCmd.SetWarnings True MsgBox "Error has been logged", vbOKOnly, "Error"

End Function

The function intentionally throws an overflow error in order to execute errHandler. This code builds a SQL INSERT INTO statement using the following information: the date, the computer’s name, the user’s name, the internal error number and description, and the module that generated the error.


About INSERT INTO

SQL’s INSERT INTO statement works well as long as you use it correctly:

  • The target table (in this case that’s the error log table) must contain every field in the INTO and VALUES clause.
  • You can omit a field from the INTO clause as long as you also omit it from the VALUES clause; these two clauses must match.
  • When including field references in the INTO clause, their order must match their placement in the table (check the table in Design view, which won’t always agree with Table view).
  • Don’t include an AutoNumber field in either clause.
  • Jet won’t complain if there’s no data for a specified field, unless doing so violates a field constraint. That behavior could help or hinder.
  • You can omit all of the fields from the INTO clause, but you must account for every field in the target table in the VALUES clause.


You can customize the information to fit your needs. For instance, if no one else is using the database, you won’t need the user or computer names. Just remember to delimit each item correctly. Delimiters cause a bit of a problem for the error’s description text, as quite often this text includes single quotation marks. Assigning the text to a string variable, separate from the SQL string variable, makes the text easier to handle.

You must add this capability to every procedure to maintain a comprehensive log. In addition, before executing the code, create the error log table. The name of the example’s table is tblErrorLog, and it contains the following fields:

ErrDate: Date/Time

CompName: Text

UsrName: Text

ErrNumber: Numeric

ErrDescription: Text

ErrModule: Text

UserName and Computer Name are reserved words; even though those labels are more meaningful, you can’t use them to name a field or variable.

You can execute the code from inside the VBE. To do so, position the cursor anywhere inside the procedure’s code and press F5. Clear the message shown in Figure A. Open tblErrorLog to see the error record shown in Figure B.

Figure A

figure a

Clear the informational message.

Figure B

figure b

The table shows the new error record.

A project-level routine

Inserting error -logging code into every procedure works, but it’s inefficient. Consider calling a dedicated function, like the one in Listing B, instead. Call LogError() from each procedure’s error handling routine, as the procedure in Listing C shows. (Listing B and Listing C are in the download as basErrorLog2.bas.)

Listing B: LogError()

Public Function LogError()  'Log error information to tblErrorLog. Dim strDescription As String Dim strSQL As String strDescription = Chr(34) & Err.Description & Chr(34) strSQL = "INSERT INTO tblErrorLog (ErrDate, CompName, UsrName, " _ & " ErrNumber, ErrDescription, ErrModule)" _ & " VALUES(#" & Now() & "#, '" & Environ("computername") _ & "', '" & CurrentUser & "', " & Err.Number _ & ", " & strDescription & ", '" & VBE.ActiveCodePane.CodeModule & "')" DoCmd.SetWarnings False DoCmd.RunSQL strSQL DoCmd.SetWarnings True

End Function

Listing C: ThrowError()

Function ThrowError()  On Error GoTo errHandler Err.Raise 6 Exit Function

errHandler:  Call LogError MsgBox "Error has been logged", vbOKOnly, "Error"

End Function

When ThrowError() experiences an error, VBA passes that error to errHandler, which calls LogError(). The LogError() function inserts a new record using the error information into tblErrorLog and then returns to ThrowError().

A more compact solution

The one disadvantage to using pure SQL is that the statement can grow rather long and unwieldy. If you’re not comfortable writing SQL, this solution might be a little difficult for you. There are other reasons to avoid SQL:

  • If there are any plans for upsizing to SQL Server, avoid using Jet SQL, as SQL Server uses Transact-SQL (T-SQL). You’ll have to modify the SQL code so that SQL Server can use it.
  • If you’re using Access to work with SQL Server tables, the Jet SQL will fail. You could use a Pass-Through query, but you must be familiar with T-SQL.

An ActiveX Data Object (ADO) Recordset presents a more versatile solution than pure SQL. The code in Listing D (basErrorLog3.bas in the download) uses ADO to log errors.

Listing D: LogError()

Public Function LogError()  'Log error information to tblErrorLog using ADO. Dim cnn As New ADODB.Connection Dim rst As New ADODB.Recordset

  Set cnn = CurrentProject.Connection  rst.Open "SELECT * FROM tblErrorLog", cnn, _ adOpenKeyset, adLockOptimistic

  With rst    .AddNew !ErrDate = Now() !CompName = Environ("computername") !UsrName = CurrentUser !ErrNumber = Err.Number !ErrDescription = Err.Description !ErrModule = VBE.ActiveCodePane.CodeModule .Update End With

  rst.Close  Set rst = Nothing Set cnn = Nothing

End Function

Execute ThrowError(), and the results are the same. The only difference is that the ADO version is more versatile because it will run against a SQL Server backend, as long as you establish the right connection (update the CurrentProject.Connection shortcut the example uses, appropriately).

Add error handling to the error logging

So far, the error-logging routines haven’t included error handling. For that reason, if you add one of these solutions as is, thoroughly test it to make sure you accommodate all possible errors.

You might want to add error handling to the error-logging routine, because any error within the error-logging routine will write over the current error properties you’re trying to log. Passing the error-logging information as shown in Listing E is a simple solution. As with all the previous examples, call the error logging function by executing ThrowError() in Listing F. (Listings E and F are in download file as basErrorLog4.bas.)

Listing E: LogError()

Public Function LogError(errdte As Date, comname As String, _ usernme As String, errno As Long, errdes As String, errmod As String) As Boolean 'Log error information to tblErrorLog using ADO. Dim cnn As New ADODB.Connection Dim rst As New ADODB.Recordset Dim varErrors As Variant Dim varFields As Variant On Error GoTo errHandler

  Err.Raise 5

  varFields = Array("ErrDate", "CompName", "UsrName", _   "ErrNumber", "ErrDescription", "ErrModule") varErrors = Array(errdte, comname, usernme, errno, errdes, errmod)

  Set cnn = CurrentProject.Connection  rst.Open "SELECT * FROM tblErrorLog", cnn, _ adOpenKeyset, adLockOptimistic

  rst.AddNew varFields, varErrors  rst.Update

  rst.Close  Set rst = Nothing Set cnn = Nothing LogError = True Exit Function

errHandler:  Debug.Print errdte Debug.Print comname Debug.Print usernme Debug.Print errno Debug.Print errdes Debug.Print errmod Debug.Print Err.Number Debug.Print Err.Description

  Set rst = Nothing  Set cnn = Nothing LogError = False End Function

Listing F: ThrowError()

Sub ThrowError()  On Error GoTo errHandler Dim booLogError As Boolean Err.Raise 6 Exit Sub

errHandler:  booLogError = LogError(Now(), Environ("computername"), CurrentUser, _ Err.Number, Err.Description, VBE. _ ActiveCodePane.CodeModule) If booLogError Then MsgBox "Error has been logged", vbOKOnly, "Error" ElseIf booLogError = False Then MsgBox "Error wasn't logged", vbOKOnly, "Error" End If

End Sub

This version of ThrowError() passes the current error information to LogError(), which purposely throws another error in order to execute its error-handling routine. Of course, when applying this to your own work, you’ll want to delete LogError()’s Err.Raise statement. The error-handling routine prints the error values only to verify that the original error values still exist, even after a new error occurs. How you handle those values will be up to you. Just remember, as is, their scope is specific to LogError(). Once VBA returns flow to ThrowError(), they’re gone. The array presents an easy but alternate way to update the log table. Stick with the ADO solution if you’re working with SQL Server tables.

Notice that LogError() is now a Boolean function procedure (no longer a subprocedure as before). If VBA successfully logs the error, the function returns True; if not, the function returns False. The calling subprocedure (Listing F) contains an enhanced If statement that returns the appropriate message, depending on whether LogError() returns True or False. Figure C shows the simple message shown when the code fails to log an error. When you apply this technique to your own procedures, you’ll want to include specific error handling. As is, LogError() merely maps the flow for you.

Figure C

figure c

Let users know when the VBA is unable to log an error.

Worth noting

This is a good procedure to add to your code library. Just drop it into any database. cialis weekend pill If you’re working with an older database, make sure to reference the ActiveX Data Objects library (ADO).

Some developers don’t like Environ(); they complain that it’s unstable. If you have trouble with this function and you need to track the computer, use the API GetComputerNameA() function instead.

Remember, you must create the log table manually. You can, however, add code that creates the table if it doesn’t already exist.

Easy error log

If you Google error logging in Microsoft Access, you’ll find a number of complex solutions. The process doesn’t have to be hard to be good. Most of us need only a simple function to log specific information about the current error, for later use.

Permalink • Print • Comment
« Previous PageNext Page »
Made with WordPress and the Semiologic theme and CMS • Sky Gold skin by Denis de Bernardy