MessBox For A Null Entry

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

I need a messBox to pop up stating to enter data into a null field. (If a
field is left blank by mistake)
I think an If statement would do. My field is named "Cert Number" Thanks
for the help...Randy
 
Hi Randy,

I would use the Form's Before Update to check for this.
Something like so:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Cert Number]) Then
MsgBox "Enter Cert Number First"
Me.[Cert Number].SetFocus
Cancel = True
End If
End Sub

Also, you could set that field to be "Required" at the
table level so no records will be created without a value
in that field.

You may also want to consider not having spaces in your
field names as well as form objects. It helps with coding.

Hope that helps,
Jeff Conrad
Bend, Oregon
 
Thanks alot...Randy
Jeff Conrad said:
Hi Randy,

I would use the Form's Before Update to check for this.
Something like so:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Cert Number]) Then
MsgBox "Enter Cert Number First"
Me.[Cert Number].SetFocus
Cancel = True
End If
End Sub

Also, you could set that field to be "Required" at the
table level so no records will be created without a value
in that field.

You may also want to consider not having spaces in your
field names as well as form objects. It helps with coding.

Hope that helps,
Jeff Conrad
Bend, Oregon
-----Original Message-----
I need a messBox to pop up stating to enter data into a
null field. (If a field is left blank by mistake)
I think an If statement would do. My field is
named "Cert Number" Thanks
for the help...Randy
 
You're welcome Randy.
Glad to help.

Jeff Conrad
Bend, Oregon
-----Original Message-----
Thanks alot...Randy
Jeff Conrad said:
Hi Randy,

I would use the Form's Before Update to check for this.
Something like so:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Cert Number]) Then
MsgBox "Enter Cert Number First"
Me.[Cert Number].SetFocus
Cancel = True
End If
End Sub

Also, you could set that field to be "Required" at the
table level so no records will be created without a value
in that field.

You may also want to consider not having spaces in your
field names as well as form objects. It helps with coding.

Hope that helps,
Jeff Conrad
Bend, Oregon
-----Original Message-----
I need a messBox to pop up stating to enter data into a
null field. (If a field is left blank by mistake)
I think an If statement would do. My field is
named "Cert Number" Thanks
for the help...Randy


.
 
I tried this code. A mesBox pops up correctly, but when you click on ok a
screen pops up stating "Object doesn't support this property or method".
When I click on debub this part of the code is highlighted: "Me.[Cert
Number].SetFocus" any ideas.
Jeff Conrad said:
Hi Randy,

I would use the Form's Before Update to check for this.
Something like so:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Cert Number]) Then
MsgBox "Enter Cert Number First"
Me.[Cert Number].SetFocus
Cancel = True
End If
End Sub

Also, you could set that field to be "Required" at the
table level so no records will be created without a value
in that field.

You may also want to consider not having spaces in your
field names as well as form objects. It helps with coding.

Hope that helps,
Jeff Conrad
Bend, Oregon
-----Original Message-----
I need a messBox to pop up stating to enter data into a
null field. (If a field is left blank by mistake)
I think an If statement would do. My field is
named "Cert Number" Thanks
for the help...Randy
 
It would appear that Cert Number is the name of a field in the form's
recordsource, not the name of a control bound to that field. In the SetFocus
setp, replace [Cert Number] with the actual name of the control that is
bound to that field.

--
Ken Snell
<MS ACCESS MVP>

Randy said:
I tried this code. A mesBox pops up correctly, but when you click on ok a
screen pops up stating "Object doesn't support this property or method".
When I click on debub this part of the code is highlighted: "Me.[Cert
Number].SetFocus" any ideas.
Jeff Conrad said:
Hi Randy,

I would use the Form's Before Update to check for this.
Something like so:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Cert Number]) Then
MsgBox "Enter Cert Number First"
Me.[Cert Number].SetFocus
Cancel = True
End If
End Sub

Also, you could set that field to be "Required" at the
table level so no records will be created without a value
in that field.

You may also want to consider not having spaces in your
field names as well as form objects. It helps with coding.

Hope that helps,
Jeff Conrad
Bend, Oregon
-----Original Message-----
I need a messBox to pop up stating to enter data into a
null field. (If a field is left blank by mistake)
I think an If statement would do. My field is
named "Cert Number" Thanks
for the help...Randy
 
The control name (Textbox) is "Certificate Number" the control source is
"Cert Number" the forms record source is "Analysis Form" I hope this helps.
Ken Snell said:
It would appear that Cert Number is the name of a field in the form's
recordsource, not the name of a control bound to that field. In the SetFocus
setp, replace [Cert Number] with the actual name of the control that is
bound to that field.

--
Ken Snell
<MS ACCESS MVP>

Randy said:
I tried this code. A mesBox pops up correctly, but when you click on ok a
screen pops up stating "Object doesn't support this property or method".
When I click on debub this part of the code is highlighted: "Me.[Cert
Number].SetFocus" any ideas.
Jeff Conrad said:
Hi Randy,

I would use the Form's Before Update to check for this.
Something like so:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Cert Number]) Then
MsgBox "Enter Cert Number First"
Me.[Cert Number].SetFocus
Cancel = True
End If
End Sub

Also, you could set that field to be "Required" at the
table level so no records will be created without a value
in that field.

You may also want to consider not having spaces in your
field names as well as form objects. It helps with coding.

Hope that helps,
Jeff Conrad
Bend, Oregon

-----Original Message-----
I need a messBox to pop up stating to enter data into a
null field. (If a field is left blank by mistake)
I think an If statement would do. My field is
named "Cert Number" Thanks
for the help...Randy
 
Hi Randy,

Looks like you still need some help.

Try this code instead:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Certificate Number]) Then
MsgBox "Enter Certification Number First"
Me.[Certificate Number].SetFocus
Cancel = True
End If
End Sub

Hope that fixes it.
Thanks for the backup Ken!

Jeff Conrad
Bend, Oregon
-----Original Message-----
The control name (Textbox) is "Certificate Number" the control source is
"Cert Number" the forms record source is "Analysis Form" I hope this helps.
It would appear that Cert Number is the name of a field in the form's
recordsource, not the name of a control bound to that
field. In the
SetFocus
setp, replace [Cert Number] with the actual name of the control that is
bound to that field.

--
Ken Snell
<MS ACCESS MVP>

Randy said:
I tried this code. A mesBox pops up correctly, but
when you click on ok
a
screen pops up stating "Object doesn't support this property or method".
When I click on debub this part of the code is highlighted: "Me.[Cert
Number].SetFocus" any ideas.
Hi Randy,

I would use the Form's Before Update to check for this.
Something like so:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Cert Number]) Then
MsgBox "Enter Cert Number First"
Me.[Cert Number].SetFocus
Cancel = True
End If
End Sub

Also, you could set that field to be "Required" at the
table level so no records will be created without a value
in that field.

You may also want to consider not having spaces in your
field names as well as form objects. It helps with coding.

Hope that helps,
Jeff Conrad
Bend, Oregon

-----Original Message-----
I need a messBox to pop up stating to enter data into a
null field. (If a field is left blank by mistake)
I think an If statement would do. My field is
named "Cert Number" Thanks
for the help...Randy


.
 
This works fine, but only after the last field is entered and is ready to
advance to a new record, not immediately after the "Certificate Number"
control. Is this the way it should be? Thanks again for all your help.,
Jeff Conrad said:
Hi Randy,

Looks like you still need some help.

Try this code instead:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Certificate Number]) Then
MsgBox "Enter Certification Number First"
Me.[Certificate Number].SetFocus
Cancel = True
End If
End Sub

Hope that fixes it.
Thanks for the backup Ken!

Jeff Conrad
Bend, Oregon
-----Original Message-----
The control name (Textbox) is "Certificate Number" the control source is
"Cert Number" the forms record source is "Analysis Form" I hope this helps.
It would appear that Cert Number is the name of a field in the form's
recordsource, not the name of a control bound to that
field. In the
SetFocus
setp, replace [Cert Number] with the actual name of the control that is
bound to that field.

--
Ken Snell
<MS ACCESS MVP>

I tried this code. A mesBox pops up correctly, but
when you click on ok
a
screen pops up stating "Object doesn't support this property or method".
When I click on debub this part of the code is highlighted: "Me.[Cert
Number].SetFocus" any ideas.
Hi Randy,

I would use the Form's Before Update to check for this.
Something like so:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Cert Number]) Then
MsgBox "Enter Cert Number First"
Me.[Cert Number].SetFocus
Cancel = True
End If
End Sub

Also, you could set that field to be "Required" at the
table level so no records will be created without a value
in that field.

You may also want to consider not having spaces in your
field names as well as form objects. It helps with coding.

Hope that helps,
Jeff Conrad
Bend, Oregon

-----Original Message-----
I need a messBox to pop up stating to enter data into a
null field. (If a field is left blank by mistake)
I think an If statement would do. My field is
named "Cert Number" Thanks
for the help...Randy


.
 
Jeff's code is designed to work just as you observe: when you've completed
all the entries for the record on which you are working.

If you want the code to run after you finish with Certificate Number
control, then the code needs to be put in the BeforeUpdate event of the
Certificate Number control.


--
Ken Snell
<MS ACCESS MVP>

Randy said:
This works fine, but only after the last field is entered and is ready to
advance to a new record, not immediately after the "Certificate Number"
control. Is this the way it should be? Thanks again for all your help.,
Jeff Conrad said:
Hi Randy,

Looks like you still need some help.

Try this code instead:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Certificate Number]) Then
MsgBox "Enter Certification Number First"
Me.[Certificate Number].SetFocus
Cancel = True
End If
End Sub

Hope that fixes it.
Thanks for the backup Ken!

Jeff Conrad
Bend, Oregon
-----Original Message-----
The control name (Textbox) is "Certificate Number" the control source is
"Cert Number" the forms record source is "Analysis Form" I hope this helps.
It would appear that Cert Number is the name of a field in the form's
recordsource, not the name of a control bound to that field. In the
SetFocus
setp, replace [Cert Number] with the actual name of the control that is
bound to that field.

--
Ken Snell
<MS ACCESS MVP>

I tried this code. A mesBox pops up correctly, but when you click on ok
a
screen pops up stating "Object doesn't support this property or method".
When I click on debub this part of the code is highlighted: "Me.[Cert
Number].SetFocus" any ideas.
Hi Randy,

I would use the Form's Before Update to check for this.
Something like so:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Cert Number]) Then
MsgBox "Enter Cert Number First"
Me.[Cert Number].SetFocus
Cancel = True
End If
End Sub

Also, you could set that field to be "Required" at the
table level so no records will be created without a value
in that field.

You may also want to consider not having spaces in your
field names as well as form objects. It helps with coding.

Hope that helps,
Jeff Conrad
Bend, Oregon

-----Original Message-----
I need a messBox to pop up stating to enter data into a
null field. (If a field is left blank by mistake)
I think an If statement would do. My field is
named "Cert Number" Thanks
for the help...Randy






.
 
Hi Randy,

Well to answer your question, "Is this the way it *should*
be?", I would have to say, "It's really the most
*preferred* way to do it."

Here's why:
You can never completely control what users do!
Trust me on that!

You could use the text box's Exit event to check for a
null entry like this:

Private Sub Certificate_Number_Exit(Cancel As Integer)
If IsNull(Me.[Certificate Number]) Then
MsgBox "Enter Certificate Number First"
Me.[Certificate Number].SetFocus
Cancel = True
End If
End Sub

However, this event will NEVER fire unless they tab into
or click into this control. What happens if the user skips
around the data entry form with the mouse? You can't
really control what they will do. Also, from a personal
standpoint, you don't want to antagonize your users by
having a similar message box appear after EVERY required
control! I would rather see one message box come up
pointing out what fields I missed at the end.

In the end you need to decide what route you would like to
take, but I think the *best* way to go is to use the
Form's Before Update event.

Good luck,
Jeff Conrad
Bend, Oregon
-----Original Message-----
This works fine, but only after the last field is entered
and is ready to advance to a new record, not immediately
after the "Certificate Number" control. Is this the way
it should be? Thanks again for all your help.,

Jeff Conrad said:
Hi Randy,

Looks like you still need some help.

Try this code instead:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Certificate Number]) Then
MsgBox "Enter Certification Number First"
Me.[Certificate Number].SetFocus
Cancel = True
End If
End Sub

Hope that fixes it.
Thanks for the backup Ken!

Jeff Conrad
Bend, Oregon
-----Original Message-----
The control name (Textbox) is "Certificate Number" the control source is
"Cert Number" the forms record source is "Analysis
Form"
I hope this helps.
It would appear that Cert Number is the name of a
field
in the form's
recordsource, not the name of a control bound to that field. In the
SetFocus
setp, replace [Cert Number] with the actual name of
the
control that is
bound to that field.

--
Ken Snell
<MS ACCESS MVP>

I tried this code. A mesBox pops up correctly, but when you click on ok
a
screen pops up stating "Object doesn't support this property or method".
When I click on debub this part of the code is highlighted: "Me.[Cert
Number].SetFocus" any ideas.
Hi Randy,

I would use the Form's Before Update to check for this.
Something like so:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Cert Number]) Then
MsgBox "Enter Cert Number First"
Me.[Cert Number].SetFocus
Cancel = True
End If
End Sub

Also, you could set that field to be "Required"
at
the
table level so no records will be created
without a
value
in that field.

You may also want to consider not having spaces
in
your
field names as well as form objects. It helps
with
coding.
Hope that helps,
Jeff Conrad
Bend, Oregon

-----Original Message-----
I need a messBox to pop up stating to enter data into a
null field. (If a field is left blank by mistake)
I think an If statement would do. My field is
named "Cert Number" Thanks
for the help...Randy






.


.
 
You have an excellent point, I didn't think of that..Thanks again for your
Help...Randy
Jeff Conrad said:
Hi Randy,

Well to answer your question, "Is this the way it *should*
be?", I would have to say, "It's really the most
*preferred* way to do it."

Here's why:
You can never completely control what users do!
Trust me on that!

You could use the text box's Exit event to check for a
null entry like this:

Private Sub Certificate_Number_Exit(Cancel As Integer)
If IsNull(Me.[Certificate Number]) Then
MsgBox "Enter Certificate Number First"
Me.[Certificate Number].SetFocus
Cancel = True
End If
End Sub

However, this event will NEVER fire unless they tab into
or click into this control. What happens if the user skips
around the data entry form with the mouse? You can't
really control what they will do. Also, from a personal
standpoint, you don't want to antagonize your users by
having a similar message box appear after EVERY required
control! I would rather see one message box come up
pointing out what fields I missed at the end.

In the end you need to decide what route you would like to
take, but I think the *best* way to go is to use the
Form's Before Update event.

Good luck,
Jeff Conrad
Bend, Oregon
-----Original Message-----
This works fine, but only after the last field is entered
and is ready to advance to a new record, not immediately
after the "Certificate Number" control. Is this the way
it should be? Thanks again for all your help.,

Jeff Conrad said:
Hi Randy,

Looks like you still need some help.

Try this code instead:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Certificate Number]) Then
MsgBox "Enter Certification Number First"
Me.[Certificate Number].SetFocus
Cancel = True
End If
End Sub

Hope that fixes it.
Thanks for the backup Ken!

Jeff Conrad
Bend, Oregon

-----Original Message-----
The control name (Textbox) is "Certificate Number" the
control source is
"Cert Number" the forms record source is "Analysis Form"
I hope this helps.
message
It would appear that Cert Number is the name of a field
in the form's
recordsource, not the name of a control bound to that
field. In the
SetFocus
setp, replace [Cert Number] with the actual name of the
control that is
bound to that field.

--
Ken Snell
<MS ACCESS MVP>

I tried this code. A mesBox pops up correctly, but
when you click on ok
a
screen pops up stating "Object doesn't support this
property or method".
When I click on debub this part of the code is
highlighted: "Me.[Cert
Number].SetFocus" any ideas.
message
Hi Randy,

I would use the Form's Before Update to check for
this.
Something like so:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Cert Number]) Then
MsgBox "Enter Cert Number First"
Me.[Cert Number].SetFocus
Cancel = True
End If
End Sub

Also, you could set that field to be "Required" at
the
table level so no records will be created without a
value
in that field.

You may also want to consider not having spaces in
your
field names as well as form objects. It helps with
coding.

Hope that helps,
Jeff Conrad
Bend, Oregon

-----Original Message-----
I need a messBox to pop up stating to enter data
into a
null field. (If a field is left blank by mistake)
I think an If statement would do. My field is
named "Cert Number" Thanks
for the help...Randy






.


.
 
Hi Randy,

Glad you got everything working now.
Come back any time.

Jeff Conrad
Bend, Oregon
-----Original Message-----
You have an excellent point, I didn't think of that..Thanks again for your
Help...Randy
Jeff Conrad said:
Hi Randy,

Well to answer your question, "Is this the way it *should*
be?", I would have to say, "It's really the most
*preferred* way to do it."

Here's why:
You can never completely control what users do!
Trust me on that!

You could use the text box's Exit event to check for a
null entry like this:

Private Sub Certificate_Number_Exit(Cancel As Integer)
If IsNull(Me.[Certificate Number]) Then
MsgBox "Enter Certificate Number First"
Me.[Certificate Number].SetFocus
Cancel = True
End If
End Sub

However, this event will NEVER fire unless they tab into
or click into this control. What happens if the user skips
around the data entry form with the mouse? You can't
really control what they will do. Also, from a personal
standpoint, you don't want to antagonize your users by
having a similar message box appear after EVERY required
control! I would rather see one message box come up
pointing out what fields I missed at the end.

In the end you need to decide what route you would like to
take, but I think the *best* way to go is to use the
Form's Before Update event.

Good luck,
Jeff Conrad
Bend, Oregon
-----Original Message-----
This works fine, but only after the last field is entered
and is ready to advance to a new record, not immediately
after the "Certificate Number" control. Is this the way
it should be? Thanks again for all your help.,

Hi Randy,

Looks like you still need some help.

Try this code instead:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Certificate Number]) Then
MsgBox "Enter Certification Number First"
Me.[Certificate Number].SetFocus
Cancel = True
End If
End Sub

Hope that fixes it.
Thanks for the backup Ken!

Jeff Conrad
Bend, Oregon

-----Original Message-----
The control name (Textbox) is "Certificate Number" the
control source is
"Cert Number" the forms record source is "Analysis Form"
I hope this helps.
message
It would appear that Cert Number is the name of a field
in the form's
recordsource, not the name of a control bound to that
field. In the
SetFocus
setp, replace [Cert Number] with the actual name
of
the
control that is
bound to that field.

--
Ken Snell
<MS ACCESS MVP>

I tried this code. A mesBox pops up correctly, but
when you click on ok
a
screen pops up stating "Object doesn't support this
property or method".
When I click on debub this part of the code is
highlighted: "Me.[Cert
Number].SetFocus" any ideas.
message
Hi Randy,

I would use the Form's Before Update to check for
this.
Something like so:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[Cert Number]) Then
MsgBox "Enter Cert Number First"
Me.[Cert Number].SetFocus
Cancel = True
End If
End Sub

Also, you could set that field to
be "Required"
at
the
table level so no records will be created without a
value
in that field.

You may also want to consider not having
spaces
in
your
field names as well as form objects. It helps with
coding.

Hope that helps,
Jeff Conrad
Bend, Oregon

-----Original Message-----
I need a messBox to pop up stating to enter data
into a
null field. (If a field is left blank by mistake)
I think an If statement would do. My field is
named "Cert Number" Thanks
for the help...Randy






.



.


.
 
Back
Top