Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Richard Rueda - 17 Mar 2005 17:51 GMT
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 S - 17 Mar 2005 18:01 GMT
Try:

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

> Hi there
>
[quoted text clipped - 19 lines]
>
> Richard
Ken Snell [MVP] - 17 Mar 2005 18:03 GMT
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

Signature

       Ken Snell
<MS ACCESS MVP>

> Hi there
>
[quoted text clipped - 22 lines]
>
> Richard
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.