The brackets worked but still nothing happens when I test
the form. When I put the task beginning with 260 and tab
through the memo field....no message pops up and can still
continue to next record.
This is what I have entered.....
Private Sub Misc_BeforeUpdate(Cancel As Integer)
If Left(Me.[Job Name], 3) = "161" Or Left(Me.[Job Name],
3) = "260" Then
If Nz(Me.Misc, "") = "" Then
Cancel = True
MsgBox "Miscellaneous explanation is required!",
vbOKOnly + vbInformation
Me.txtMisc.SetFocus
End If
End If
End Sub
What have I done wrong?
Sorry to be so dense.
-----Original Message-----
Your correct, spaces will cause a problem. I was referring to the name of
the control (textbox) not the field, but you should be able to make it work
either way. For names with spaces, put brackets around them.
Example:
Me.[My Textbox]
or
[Table Name].[Field Name]
--
Wayne Morgan
Microsoft Access MVP
Wayne,
Thank you for your idea. I think this would work if only
my text field name didn't have a space in the name...."Job
Name". I continue to receive an error message
"Compile error:
Expected list separator or )"
I believe this error is because of the space in the field
name. Is there a solution for this?
Thanks so much.
-----Original Message-----
This can be done on a form. In the BeforeUpdate event of
the form, check the
value of the task fields left 3 characters and if they
meet the
specification, check for a value in the memo field. If
the memo field is
blank, Cancel the update and alert the user.
Example:
If Left(Me.txtTask, 3) = "161" Or Left(Me.txtTask, 3)
= "260" Then
If Nz(Me.txtMemo, "") = "" Then
Cancel = True
Msgbox "The memo is required!", vbOkOnly +
vbInformation
Me.txtMemo.SetFocus
End If
End If
--
Wayne Morgan
Microsoft Access MVP
message
Hi,
I have a form that has a field for 'job description'
which
is a combo box and the tasks listed begin with a 3 digit
code. Also a memo field that is for explanation of the
task if needed. I've been asked to make this memo
field a
required field if the task selected begins with 161 or
260
otherwise it is not required. I'm not even sure if this
is possible, but I would greatly appreciate any ideas.
Thanks from Iowa.
.
.