Help with Runtime Error 424

boblife42

Registered User.
Local time
Yesterday, 16:53
Joined
May 30, 2008
Messages
32
I am getting a runtime error 424 Object Required, for the following code
Code:
Private Sub DescProblem_LostFocus()
Dim rs As DAO.Recordset
[COLOR=Purple]Set rs = dbs.OpenRecordset(tbl_TempDescWord)[/COLOR]
Dim strArray() As String
Dim j
strArray = Split(DescProblem)
For j = 0 To UBound(strArray)

     MsgBox strArray(j)
     rs.AddNew
     rs!DescWord = strArray(j)
     rs.Update
Next
rs.close
dbs.close

End Sub
The purple text is where the debugger stops. What I am doing is taking the text entered into a textbox and splitting each word into an array so that it can be stored in a temporary table.

I appreciate any help.
 
You don't define what dbs is.

You either need to define dbs as a database, or use CurrentDb.
 
When I set it to CurrentDb I get the error message that it cannot find the input table. I have double checked the spelling on the table name, any thoughts.
 
Think you need quotes round your table name like this:

Code:
Set rs = currentdb.OpenRecordset("tbl_TempDescWord")
 
You are wonderful that worked.
Thank you, why did it need quotes for future reference.
 
Because you need to pass the datasource for the recordset as a string and strings need quotes.
 
Maybe because you didnt quote the table name?? Access now thinks the table name is a undefined variable....

Set rs = currentdb.OpenRecordset("tbl_TempDescWord")

Please go to the Code editor. Then in the menu find Tools => Options.
Now in the "Editor" tab check "Require Variable Declaration" to prevent these things from happening again.
 

Users who are viewing this thread

Back
Top Bottom