Daily Access Tips

Answering your common Microsoft Access questions…
  • rss
  • Home
  • About
  • Contact
  • Newsletter
  • Video Tutorials
  • Help Request Form

How to enhance your Microsoft Access data entry forms

July 27, 2009 | 7:12 pm

This article will offer a simple solution of how to let the person know what is needed from them on Microsoft Access data entry forms and where it is needed.

Last week I was asked for a way to give the person an on screen message while on Microsoft Access data entry forms without it requiring them to dismiss it by clicking the OK button on a message box. My reply was to have a label change it’s caption property from nothing to “The desired message…” then back to nothing using the form’s built in timer and some OnTimer event code. This article using some code similar to the last posted article.  It addresses two areas of Microsoft Access data entry forms assistance. The first is a visual clue as to where that skinny little cursor is blinking and second, what the user needs to know about the current form control that has cursor focus. The first area was addressed by changing the background color to a light shade of blue as the visual clue. The second area was addressed by having a custom message appear in a label at the top of the form. The messages are stored in the Tag property of each control that requires a message to be displayed by Microsoft Access. Data entry forms might have a message that simply lets the data entry person know that this is a required field or it might supply more about the type of information that should be entered in this field. This message is turned off when the user move to the next control on the form.

Below is a short video demonstrating how this works.

This green colored code below is all you need at the form level. It is placed in the form’s On Open Event.

Private Sub Form_Open(Cancel As Integer)
Me.SetFocus
Call SetEventHandlers(Me)

End Sub

Each form control has a tag property where you can type in the message you want to appear in the ‘lblControlMsg’ label that you will need to place on your form. If you need help finding the tag property see this video.

Place code below in a code module:

Public Sub SetEventHandlers(frm As Form)

‘Runing this routine from the OnOpen event of any form using
‘Call SetValidatorEventHandlers(Me)
‘will replace any OnGotFocus and OnLostFocus event code
‘with a call to the Highlighter function.

On Error GoTo errline
Dim ctl As Control
For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox
If ctl.Visible = True Then
ctl.OnGotFocus = “=Highlighter(true)”
ctl.OnLostFocus = “=Highlighter(false)”
End If
Case Else
End Select
Next
exitline:
Exit Sub
errline:
Select Case Err.Number
Case Else
MsgBox “Error ” & Err.Number & Chr(10) & Err.Description
GoTo exitline
End Select

End Sub

Public Function Highlighter(TurnOn As Boolean)

On Error GoTo errline
Select Case Screen.ActiveControl.ControlType
Case acTextBox, acComboBox, acListBox
If TurnOn Then
Screen.ActiveControl.BackColor = 16773857
‘requires that the name of the message control be labeled ‘lblControlMsg’
Screen.ActiveForm![lblControlMsg].Caption = Screen.ActiveControl.Tag
Else
Screen.ActiveControl.BackColor = -2147483643
Screen.ActiveForm![lblControlMsg].Caption = “”
End If
Case Else
End Select
exitline:
Exit Function
errline:
Select Case Err.Number
‘Form window not visible yet to see Screen.ActiveControl
‘(Only needed when setting event handlers by code)

Case 2475
Resume exitline
Case Else
MsgBox “Error ” & Err.Number & Chr(10) & Err.Description
GoTo exitline
Resume Next
End Select
End Function

Let me know how this worked for you by entering your comments and suggestions.


Bookmark and Share

Categories
Access Custom Functions, Access Forms, Programming Code
Comments rss
Comments rss
Trackback
Trackback

« Automating Microsoft Access Email Alerts Speedup Data Entry of City State Zip Code Using A Dlookup »

9 Responses to “How to enhance your Microsoft Access data entry forms”

« Older Comments
  1. Anonymous says:
    August 23, 2010 at 8:01 am

    Thanks

  2. Jim says:
    February 19, 2011 at 1:06 pm

    Hi, I am new to Access – and there is something in the instructions (which must be very obvious to most) that I can not figure out. Copying the code to a module was easy enough, but getting the On Open Event to link over to the code has eluded me. I am referring to instructions below… I can’t make it work on my form.

    This green colored code below is all you need at the form level. It is placed in the form’s On Open Event.
    Private Sub Form_Open(Cancel As Integer)
    Me.SetFocus
    Call SetEventHandlers(Me)
    End Sub

    Love your site – there is much useful information here – I f you could explain what I am missing, I would really appreciate it
    Thanks! Jim C.

  3. admin says:
    February 20, 2011 at 8:56 pm

    This probably would be easier if I saw what you did to your Access file and corrected what was needed.
    http:/www.myaccessprogram.com contact page will help you to get with me most directly.

  4. Lee says:
    March 28, 2011 at 8:00 am

    Bob,
    That is a very nice concise tip on the Highlighter. I have already included it in our Home Owners Association tracking application that my wife uses to handle the dues. And it only took a few minutes to implement.

    Thanks,
    Lee

« Older Comments

Leave a Reply

Click here to cancel reply.


Categories

  • Access Custom Functions
  • Access Forms
  • Access Queries
  • Access Tables
  • Miscellaneous
  • Programming Code

Recent Posts

  • Access MVP Recognition
  • Microsoft Access 2010 Release News
  • Microsoft Access Security All Versions
  • Not For Null

Discounted Access Books

Get Discounted Access Books!

Bob Heifler

  • About
  • Contact
  • Newsletter
  • Video Tutorials

Access Resources

  • Microsoft Access Demonstration Files
  • Move data from Access to Excel
  • MyAccessProgram.com
  • Services Offered
  • Tips and Best Practices
  • Video Tutorials

Discounted Access Books

Get Discounted Access Books!

more help…

Microsoft Access Help

Bookmark and Share
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox