Solved

Error 424 Object Required

Posted on 2012-04-07
6
353 Views
Last Modified: 2012-04-08
This line of code throws the error...

Me.PossibleTotal = (IIf([Symptom1] Is Not Null, 1, 0) + IIf([Symptom2] Is Not Null, 1, 0) + IIf([Symptom3] Is Not Null, 1, 0) + IIf([Symptom4] Is Not Null, 1, 0) + IIf([Symptom5] Is Not Null, 1, 0) + IIf([Stiffness1] Is Not Null, 1, 0) + IIf([Stiffness2] Is Not Null, 1, 0) + _
    IIf([Pain1] Is Not Null, 1, 0) + IIf([Pain2] Is Not Null, 1, 0) + IIf([Pain3] Is Not Null, 1, 0) + IIf([Pain4] Is Not Null, 1, 0) + IIf([Pain5] Is Not Null, 1, 0) + IIf([Pain6] Is Not Null, 1, 0) + IIf([Pain7] Is Not Null, 1, 0) + IIf([Pain8] Is Not Null, 1, 0) + IIf([Pain9] Is Not Null, 1, 0) + _
    IIf([ADL1] Is Not Null, 1, 0) + IIf([ADL2] Is Not Null, 1, 0) + IIf([ADL3] Is Not Null, 1, 0) + IIf([ADL4] Is Not Null, 1, 0) + IIf([ADL5] Is Not Null, 1, 0) + IIf([ADL6] Is Not Null, 1, 0) + IIf([ADL7] Is Not Null, 1, 0) + IIf([ADL8] Is Not Null, 1, 0) + IIf([ADL9] Is Not Null, 1, 0) + IIf([ADL10] Is Not Null, 1, 0) + IIf([ADL11] Is Not Null, 1, 0) + IIf([ADL12] Is Not Null, 1, 0) + IIf([ADL13] Is Not Null, 1, 0) + _
    IIf([ADL14] Is Not Null, 1, 0) + IIf([ADL15] Is Not Null, 1, 0) + IIf([ADL16] Is Not Null, 1, 0) + IIf([ADL17] Is Not Null, 1, 0) + IIf([Squat1] Is Not Null, 1, 0) + IIf([Run2] Is Not Null, 1, 0) + IIf([Jump3] Is Not Null, 1, 0) + IIf([Twist4] Is Not Null, 1, 0) + IIf([Kneel5] Is Not Null, 1, 0) + IIf([QL1] Is Not Null, 1, 0) + IIf([QL2] Is Not Null, 1, 0) + IIf([QL3] Is Not Null, 1, 0) + IIf([QL4] Is Not Null, 1, 0)) * 100
0
Comment
Question by:rawilken
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 17

Expert Comment

by:ramrom
ID: 37820177
More info, please.

Is this VBA code in an Access Project?

What module and procedure is it in?

How do you know for sure that that is the offending line?

Does the error get raised when you compile or execute?
0
 
LVL 75
ID: 37820374
Yikes. I believe this is officially a new record for Nested IIF()'s ...
Are you familiar with the Switch statement ?

mx
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 220 total points
ID: 37820646
That line does not make any sense.

Me.PossibleTotal is a property or class level variable.

The code with the iif and brackets [] looks like Access SQL. The notion of Null does not exist in VB.Net, and brackets are almost never used.

You cannot mix VB code and Access SQL that way. It is as if you were mixing VB and Java code in the same line of code. You cannot execute an SQL command the way you are doing it.

First, a SQL command must be defined as a String, between double quotes "".

Second, the command needs to be executed through a Command object (OleDBCommand or ODBCCommand for Access) before it returns a value.

Third instead of having to work with such strange SQL commands, I would redesign the database so that it does not accept nulls. Simply set 0 as a default value. You command would thus become a simple addition, without the iifs that are known to be an importance performance hit. With the numbers of iif you have, I think you would feel it.

But none of this would have given you your error anyway. The only thing that is an object in your code is Me. Me represents the object in which the code is executing. If you are in a module, there is no object and Me would trigger that error.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 17

Expert Comment

by:ramrom
ID: 37821207
DatabaseMX: NO nested IIF - just a lot of IIFs added up. Switch would not apply here.

JamesBurger: No SQL here - just an expression probably referring to controls on a form.

rawilken: please let us know how the answer helped. What did you change to stop the error?
0
 
LVL 40
ID: 37821222
@ramrom

The line is VB code because it uses Me to reference the current instance. Null does not exist in VB that uses Nothing instead. The brackets around fields name are a trademark of Access generated queries. So everything points out to a SQL command.
0
 
LVL 75
ID: 37821447
@ramrom
What actually resolved the issue?

mx
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question