By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,503 Members | 2,730 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,503 IT Pros & Developers. It's quick & easy.

Run-Time Error '424 - Object Required

P: 48
Good Morning Experts,

I spent all weekend working on this and got absolutely no where.

I have a database with an input form that runs an append query to append to a table.

Form Name: Poetry
Append Query Name: Created_Submitted_Work
Table Name: Created_Submitted

I have also created what I hope is an update query. The purpose of this query is to check whether a record exists that contains the words “Not Applicable” in the table field [Submitted To]. I am trying to test this in stages by verifying I can examine the table field for “Not Applicable” in the (Created_Submitted.[Submitted To]) field after clicking the Add Record command button.

I am constantly getting the message “Run-Time Error '424 - Object Required”. But I don’t know what it is referring to. I assume it is not able to access the table to verify the field contents. If that is the case I have no idea how to make it happen. If that is not the case, then again, I have no idea what is causing this.

I have commented out everything in the event and am just trying to do s simple if statement to see if it works.

Here is what I used to test that:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CMD_AddRecord2_Click()
  2. If (Created_Submitted.[Submitted To]) = "Not Applicable" Then
  3.        MsgBox "This Worked!", vbOK, "Woo Hoo!!!"
  4.     End If
  5. End Sub
Any help would be greatly appreciated.
May 12 '08 #1
Share this Question
Share on Google+
11 Replies


nico5038
Expert 2.5K+
P: 3,072
Did you try:
Expand|Select|Wrap|Line Numbers
  1. Private Sub CMD_AddRecord2_Click()
  2. If mE.[Submitted To] = "Not Applicable" Then
  3.    MsgBox ("This Worked!", vbOK, "Woo Hoo!!!")
  4. End If
  5. End Sub
This assumes that the code is behind a form and the field is named [Submitted To] (Check the name in the Other tab of the properties window).
For referring to the field in a table a Dlookup() statement is needed.

Nic;o)
May 12 '08 #2

P: 48
Thank Nico,,

I tried using the code below and received a differnet message.

Expand|Select|Wrap|Line Numbers
  1. Private Sub CMD_AddRecord2_Click()
  2.     Dim subTo As Variant
  3.         subTo = DLookup("[Submitted To]", "Created_Submitted", "[Title] = " _
  4.         & Forms!Poetry!TxtTitle)
  5. End Sub
  6.  
When I ran this just to see if it would error I received the message "Run-time error 3075 - Syntax error (missing operator) in query expression '[Title] = Blue Jean Hoochie Mama'" . In this error Blue Jean Hoochie Mama is the name of a poem that is in the table. I want to look up the values for the Submitted To field in the Created_Submitted table where the Title field in the same table is equal to the TxtTitle field on the form Poetry.

I have tried looking up this error and found information referrinfg the apostrophes and such but the value selected does not contain any.

Thoughts???

Thanks,
Doug
May 12 '08 #3

nico5038
Expert 2.5K+
P: 3,072
Thank Nico,,

I tried using the code below and received a differnet message.

Expand|Select|Wrap|Line Numbers
  1. Private Sub CMD_AddRecord2_Click()
  2.     Dim subTo As Variant
  3.         subTo = DLookup("[Submitted To]", "Created_Submitted", "[Title] = " _
  4.         & Forms!Poetry!TxtTitle)
  5. End Sub
  6.  
When I ran this just to see if it would error I received the message "Run-time error 3075 - Syntax error (missing operator) in query expression '[Title] = Blue Jean Hoochie Mama'" . In this error Blue Jean Hoochie Mama is the name of a poem that is in the table. I want to look up the values for the Submitted To field in the Created_Submitted table where the Title field in the same table is equal to the TxtTitle field on the form Poetry.

I have tried looking up this error and found information referrinfg the apostrophes and such but the value selected does not contain any.

Thoughts???

Thanks,
Doug
Strings need to be embedded in quotes like:
Expand|Select|Wrap|Line Numbers
  1. Private Sub CMD_AddRecord2_Click()
  2.     Dim subTo As Variant
  3.         subTo = DLookup("[Submitted To]", "Created_Submitted", "[Title] = '" _
  4.         & Forms!Poetry!TxtTitle) & "'"
  5. End Sub
  6.  
The single quotes ( ' ) are hard to see, but they need to be in the WHERE parameter for every text field. Dates need surrounding #'s and numbers need nothing.

Nic;o)
May 12 '08 #4

P: 48
I got the exact same error message. I moved the right parantheses to the very end of the code you sent and got further. the problem there was that the update query wanted to update all the records whether the title field in the table matched to txttitle filed on the form or not.

I added an If statement to test it and opened up some of the code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub CMD_AddRecord2_Click()
  2. On Error GoTo Err_CMD_Add_Record2_Click
  3.  
  4.     Dim subTo As Variant
  5.  
  6.         subTo = DLookup("[Submitted To]", "Created_Submitted", "[Title] = '" _
  7.         & Forms!Poetry!TxtTitle & "'")
  8.  
  9.     If subTo = "Not Applicable" Then
  10.  
  11.         Dim stUpdate As String
  12.         stUpdate = "Created_Submitted_Query"
  13.         DoCmd.OpenQuery stUpdate, acNormal, acEdit
  14.  
  15.         CMD_Cancel.Visible = True
  16.         cmdSpecificSearch.Visible = True
  17.         lblSubmissionDetails.Visible = False
  18.         lblSubmittedTo.Visible = False
  19.         cboSubmitted.Visible = False
  20.         lblWebsite.Visible = False
  21.         TxtWebsite.Visible = False
  22.         lblType.Visible = False
  23.         TxtType.Visible = False
  24.         lblDateSubmitted.Visible = False
  25.         TxtDate.Visible = False
  26.         lblDateAdded.Visible = False
  27.         TxtDate2.Visible = False
  28.         lblAccepted.Visible = False
  29.         cboAccepted.Visible = False
  30.         CMD_Cancel.SetFocus
  31.         CMD_AddRecord2.Visible = False
  32.         CMD_Cancel2.Visible = False
  33.         CMSAllRecords.Visible = True
  34.         Me![cboTitles] = ""
  35.         Me![TxtYearCreated] = ""
  36.         Me![cboSubmittedBox] = ""
  37.         Me![cboSubmitted] = ""
  38.         Me![TxtWebsite] = ""
  39.         Me![TxtType] = ""
  40.         Me![TxtDate] = ""
  41.         Me![TxtDate2] = ""
  42.         Me![cboAccepted] = ""
  43.  
  44.     End If
  45.  
  46. Exit_CMD_Add_Record2_Click:
  47.     Exit Sub
  48.  
  49. Err_CMD_Add_Record2_Click:
  50.     MsgBox Err.Description
  51.     Resume Exit_CMD_Add_Record2_Click
  52.  
  53. End Sub
  54.  
May 12 '08 #5

nico5038
Expert 2.5K+
P: 3,072
The UPDATE query needs to hold the unique key.
Personally I use often:
Expand|Select|Wrap|Line Numbers
  1. curentdb.execute ("UPDATE tblX SET Field1 = '" & Me.FieldFromForm & "' WHERE ID=" & Me.ID)
  2.  
Nic;o)
May 12 '08 #6

P: 48
Thanks. I will try that tomororw, but I really have no idea where it goes in my code. I will have to research it in the morning.
May 12 '08 #7

nico5038
Expert 2.5K+
P: 3,072
Would be after the IF statement:

If subTo = "Not Applicable" Then

use it instead of running the UPDATE query.

Nic;o)
May 12 '08 #8

P: 48
I apologoze but I don't understand all of it. I am really struggling with this one and I don't really know why.

WHAT YOU SENT
Expand|Select|Wrap|Line Numbers
  1. curentdb.Execute ("UPDATE tblX SET Field1 = '" & Me.FieldFromForm & "' WHERE ID=" & Me.ID)
WHAT I THINK I NEED (I have bolded what I do not understand)
Expand|Select|Wrap|Line Numbers
  1. curentdb.Execute ("UPDATE Created_Submitted SET Field1 = '" & Me.TxtTitle & "' WHERE ID =" & Me.ID)
Do I need to replace Field1 with something else?
Is Where ID supposed to be the field in the table (Title) and Me.ID supposed to be the form field again?

Again, sorry for my ignorance.

Thanks,
Doug
May 13 '08 #9

P: 48
I read online that Access 2000 and 2002 will not allow the Currentdb command to work. I am using Access 2003 Sp3 on an XP machine. Do you think this be a problem for me?

Would be after the IF statement:

If subTo = "Not Applicable" Then

use it instead of running the UPDATE query.

Nic;o)
May 13 '08 #10

nico5038
Expert 2.5K+
P: 3,072
My line of code is a sample, as I don't know the table and field(s) you use.
Just open the helpfile to see the syntax and to replace my sample names with the names you need.
The ID field should be the unique identifier of the row in the table, else all rows are updated...

Nic;o)
May 13 '08 #11

NeoPa
Expert Mod 15k+
P: 31,186
I read online that Access 2000 and 2002 will not allow the Currentdb command to work. I am using Access 2003 Sp3 on an XP machine. Do you think this be a problem for me?
No, I doubt this will be a problem.

What you should understand if you're setting up multiple fields is that your UPDATE SQL string will have to include a {[Field]=Value,} for EACH of the fields to be updated.

Are you getting the picture Doug?
May 13 '08 #12

Post your reply

Sign in to post your reply or Sign up for a free account.