Monday, June 13, 2005

User Friendly Prompt for Requesting Required Information in Access Form

I have a form which has a SAVE RECORD button, which runs a Save Record Macro. The underlying form's table has a Required field. When the Required field is not populated and the SAVE RECORD button is clicked, a popup message prompts the user for the Required field. The problem is that the popup message prompts for the field name as defined in the table and in some cases this might be confusing to the user.

In order to make a user friendly popup message, you could add a condition to the Save Record Macro which checks whether the Required field control is populated or not with: is null(Required Field). If it is true, exit the macro, else continue.

1 comment:

Anonymous said...

I use these two functions very extensively:-

Function NoV(Data As Variant) As Boolean
'####################################################
'## Returns TRUE if Data is null, void, or empty ##
'## otherwise returns FALSE ##
'## Note that zero is a valid number! ##
'####################################################

On Error GoTo ErrorTrap ' an error will occur if a numeric value is held in 'Data'
' and the function tries to process it as a string, i.e. ""

NoV = False ' default value is FALSE

If IsNull(Data) Then ' data is null
NoV = True ' set returned value to TRUE
Exit Function ' no need to check further
End If

If Data = "" Then ' data is empty. Generates an error if 'Data' is numeric
NoV = True ' set returned value to TRUE
Exit Function ' no need to check further
End If

Exit Function

ErrorTrap: ' to catch errors occurring when numeric 'Data' is
Resume Next ' processed as a string

End Function

Function NoVoZ(Data As Variant) As Boolean
'#########################################################
'## Returns TRUE if Data is null, void, zero or empty ##
'# otherwise returns FALSE ##
'#########################################################

On Error GoTo ErrorTrap ' an error will occur if a numeric value is held in 'Data'
' and the function tries to process it as a string, i.e. ""

NoVoZ = False ' default value is FALSE

If IsNull(Data) Then ' data is null
NoVoZ = True ' set returned value to TRUE
Exit Function ' no need to check further
End If

If Data = "" Then ' data is empty. Generates an error if 'Data' is numeric
NoVoZ = True ' set returned value to TRUE
Exit Function ' no need to check further
End If

If Data = 0 Then ' data is zero. Generates an error if 'Data' is string
NoVoZ = True ' set returned value to TRUE
Exit Function ' no need to check further
End If

Exit Function

ErrorTrap: ' to catch errors occurring when numeric 'Data' is
Resume Next ' processed as a string

End Function