Solved

Why Access 2007 Object Required error

Posted on 2009-03-29
12
603 Views
Last Modified: 2012-05-06
I have an Access 2007 form named frmCreateBatch with a textbox named Client.  I have a string variable Where.

Here is the line of code causing the error:

Where = IIf([Forms]![frmCreateBatch]![Client] Is Not Null, [Forms]![frmCreateBatch]![Client], "Now is the time")

If I don't enter anytihing in the textbox, I simple want to set the var Where to a string value, in this sample "Now is time"

What am I missing?
0
Comment
Question by:willis1970
[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
  • 6
  • 6
12 Comments
 
LVL 75
ID: 24013489
Where  (no pun) does this code exist ?

mx
0
 

Author Comment

by:willis1970
ID: 24013529
There is a button on the from and the code is in the click event for that button.

Private Sub btnBuildBatch_Click()
Dim Where As String
Where = IIf([Forms]![frmCreateBatch]![Client] Is Not Null, [Forms]![frmCreateBatch]![Client], "Now is the time")
end sub
0
 
LVL 75
ID: 24013610
Is frmCreateBatch open when you click the button ?

mx
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:willis1970
ID: 24013836
Yes, the form is open.
0
 
LVL 75
ID: 24013886
I assume 'Client' is the Control source for a text box - and the Name property of the text box is the same?

If so ...  rename the Control to

txtClient  

then modify the code as follows:
Where = IIf([Forms]![frmCreateBatch]![txtClient] Is Not Null, [Forms]![frmCreateBatch]![txtClient], "Now is the time")

mx
0
 

Author Comment

by:willis1970
ID: 24020653
Thanks Genius for your reply.  The name of the text box is client, and there is no control source.  I did a test form, and put one text box on the form named StatusCode, and in the click event of a button,
I set a variable as follows:
SCode = [Forms]![frmCreateBatch]![statusCode]
I get the same object required error, but when I go to the immediate window and type
? [Forms]![frmCreateBatch]![statusCode], it prints "WX" which is the text in the textbox.
I seem to just get the error in code.  Very perplexing....  Any suggestions???
0
 
LVL 75
ID: 24020737
"I set a variable as follows:"

Are you doing this in form 'frmCreateBatch' ?

Can you:

1) Compact & Repair (to shrink the size),
2) Zip up the MDB (to further shrink the size)
3) Attach the file for upload here (using the 'Attach File function below) ... removing any sensitive data of course.
4** And please give a clear explanation of exactly how to reproduce the problem or what you are trying to do.

mx
0
 

Author Comment

by:willis1970
ID: 24021731
I'll get that done, and attach the file.  
Thanks, I appreciate the help.
0
 

Author Comment

by:willis1970
ID: 24022098
I created a text database with one text box, and one button.  Put any text in the text box, and click the command button.
Notice that the debug.print will print what's in the text box, but the program "crashed" with the object required error.
Any suggestions appreciated.
Test.mdb
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 24022308
Make the change below noted with asterisks

Private Sub cmdButton_Click()
    Dim Willis As String
    Debug.Print [Forms]![frmCreateBat]![statusCode]
    If Not IsNull([Forms]![frmCreateBat]![statusCode]) Then   ' **********  HERE
        Willis = [Forms]![frmCreateBat]![statusCode]
    End If
    Stop
    End
End Sub
0
 

Author Closing Comment

by:willis1970
ID: 31564069
Feel like saying "DUH!"  I guess the fact that debug.print would handled it, I missed the other (and the syntax if.... IS NOT NULL t works in a SQL statement, I missed the other.  Thanks so much for your help.
0
 
LVL 75
ID: 24023890
"Grade:  A - "Feel like saying "DUH!"  I guess the fact that debug.print would handled it, I missed the other (and the syntax if.... IS NOT NULL t works in a SQL statement, I missed the other.  Thanks so much for your help."  "

You are welcome.

mx
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

752 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