Solved

Error 424 Object Required

Posted on 2012-04-07
6
349 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
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 …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

21 Experts available now in Live!

Get 1:1 Help Now