if...then...else procedure not working - object required message

  • Thread starter Richard Rueda via AccessMonster.com
  • Start date
R

Richard Rueda via AccessMonster.com

Hi there

I am currently working on a database project which involves some custom
message boxes. What I am trying to do is check to see whether a field is
null when the save record, next, previous or exit button is clicked.

I believe the general formula is somthing like this

If Forms![Form Name]![Field Name] is Null then Msgbox("Please enter a name
into this field") else continue with the normal code

It compiles ok but when I go to run it a message box appears saying "Object
Required" but not what I want it to do which is for a message box to appear
saying that you must enter something into the field.

I have chosen to put the code on the click of the buttons so that when they
are clicked they cannot carry out their normal function until the field is
filled it therefore not allowing an empty field to be stored into the
database.


I thank you very much in advanced any help is greatly appreciated

Richard
 
M

M S

Try:

If IsNull(Forms![Form Name]![Field Name]) Then
Msgbox("Please enter a name into this field")
 
K

Ken Snell [MVP]

Always post exact copy of your code... nothing worse than providing a
solution to the wrong problem.

You need to use the IsNull function instead of "Is Null":

If IsNull(Forms![Form Name]![Field Name]) then
Msgbox("Please enter a name into this field")
Else
' code
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top