Solved

Error 424 Object Required

Posted on 2012-04-07
6
351 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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 …

803 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