Solved

Error 424 Object Required

Posted on 2012-04-07
6
350 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
  • 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET 5 Templates 2 65
C# Single Form 8 26
Set Query Column Heading parameters through VBA for CrossTab query 6 21
Get Client IP on RDS - VB.NET 15 25
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now