Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# Error 424 Object Required

Posted on 2012-04-07
Medium Priority
356 Views
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([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
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
• 2
• 2
• 2

LVL 17

Expert Comment

ID: 37820177

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

Expert Comment

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

Jacques Bourgeois (James Burger) earned 440 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

LVL 17

Expert Comment

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

Expert Comment

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

Expert Comment

ID: 37821447
@ramrom
What actually resolved the issue?

mx
0

## Featured Post

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
###### Suggested Courses
Course of the Month9 days, 8 hours left to enroll