Missing information on Form!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I used the example in the following website to tell the user that they can't
save information without entering information first.
http://www.databasedev.co.uk/required_data.html

The thing is that I have several checkboxes and a few text boxes that depend
on others. on my form and they are not all required. so i have that
function on my form but to implement it is how I don't know.

This is what I have on my before update of the form

Private Sub Form_BeforeUpdate(Cancel As Integer)
if (Me.Noreasons = 0 Or IsNull(Me.NoReasons)) And _
(Me.EmplAccess = 0 Or IsNull(Me.EmplAccess)) And _
(Me.EmplLeave = 0 Or IsNull(Me.EmplLeave)) And _
(Me.EmplLength = 0 Or IsNull(Me.EmplLength)) then _

If RequiredData(Me) Then Cancel = -1

End If

if isnull(me.bDay) then
If RequiredData(Me) Then Cancel = -1
me.bday.setfocus
end if
****************************************
For example if I don't put anything in BDay textbox I am getting a
messagebox saying data is required in text0, please ensure that this is
entered.

How do I add text to my before update to say instead of text0 to say
"Missing Birthday date" or if i did not select the checkboxes say "missing
Employee reasons"
 
Try placing, in your code, a MsgBox w/ the string imessage informing the
User...

HTH - Bob
 
How about....

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim M$ ' "$" means "As String"
M = "You Need To Enter Data In The Field"...(you finish this)
if (Me.Noreasons = 0 Or IsNull(Me.NoReasons)) And _
(Me.EmplAccess = 0 Or IsNull(Me.EmplAccess)) And _
(Me.EmplLeave = 0 Or IsNull(Me.EmplLeave)) And _
(Me.EmplLength = 0 Or IsNull(Me.EmplLength)) then _
If RequiredData(Me) Then
MsgBox M: Cancel = -1 ' (Or Cancel = True)
End If
End If

Let Me Know...Bob
 
Thanks Barnes, I have a question though, is the Dim statement/Line as follows
Dim M as string

I will try it tomorrow....
 
Dim M As String is FINE.

I always declare my Strings as a Letter & a $...IE...Dim A$, B$, C$
Works, & saves on typing. I do the same for Longs, Integers, etc.

HTH - Bob
 
Bob, I tried the method, but it did not work. The things is that if there
atleast a few things that the user need to enter/select, then only one
messagebox should come up with all that information that is required to be
entered. for now what its doing is one message for the first control I have
 
You can have a "series" of IF statements testing each Field which needs to be
entered. If the Field is entered, the code continues testing the next IF
statement(s).

Should that Field not be entered, display the MsgBox, & add after Cancel =
True: Exit Sub...so it won't continue testing any remaining IF statements.
The objective is to run Cancel = True...if ANY of the required Fields are not
entered.

If all Fields are entered, none of the IFs will run the Cancel = True.

Let me know...Bob
 
Back
Top