Force Data Entry

rjp99

Registered User.
Local time
Today, 07:17
Joined
Feb 24, 2013
Messages
43
Hello All

I've have a form (dialog) with multiple text box and list box controls on it. I want to force users to enter information into each control.

I set up a 'Before Update' event procedure and I used the following code:

Code:
If IsNull(Me.SPCGenReason) Then MsgBox "You MUST provide a reason for this transaction.", vbOKCancel

'SPCGenReason' is the name of the control and this control is a text box.

This worked initially (i.e. the message appeared when the user left the control blank) but then it just stopped working. I have no idea what could have caused this.

Can anybody:
1. explain what might have happened and
2. what I can do to RELIABLY achieve my goal of forcing users to enter information
 
I can't explain 1. Unless the end user is pressing space as the data...

The only absolutely 100% method is to use an unbound form and have a save command that then checks every input for a valid entry before updating the relevant tables.

You will find users can always get around data entry requirements if they try hard enough...

The problem with a before update event is that they can tab past that control and nothing will happen, as it hasn't been changed.
 
Is the forms Record Selectors set to No?
Is the forms Cycle set to Current Record?
 
Thanks Minty and burrina! The problem is that Before Update allows user to 'tab' pass something (Minty)... the code didn't stop working, it's just that users are 'tabbing'.

I'm going to use On Click instead.

Before I can make this work however, I need to know if it's possible to:
1. insert an empty row at the top of a list box list
2. WITHOUT inserting an empty row in the list box source table

Without an empty row at the top of the list, when the user tabs through a control, the form populates the underlying table with the first item in the list.

This is extremely dangerous (from a data integrity standpoint); having an empty row at the top of the list is the only way I can think of to prevent this.
 
IMHO the best place for data validation code is in the forms Before Update event.
 

Users who are viewing this thread

Back
Top Bottom