Help with Runtime Error 424 (1 Viewer)

boblife42

Registered User.
Local time
Today, 02:34
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.
 

DJkarl

Registered User.
Local time
Today, 04:34
Joined
Mar 16, 2007
Messages
1,028
You don't define what dbs is.

You either need to define dbs as a database, or use CurrentDb.
 

boblife42

Registered User.
Local time
Today, 02:34
Joined
May 30, 2008
Messages
32
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.
 

chergh

blah
Local time
Today, 10:34
Joined
Jun 15, 2004
Messages
1,414
Think you need quotes round your table name like this:

Code:
Set rs = currentdb.OpenRecordset("tbl_TempDescWord")
 

boblife42

Registered User.
Local time
Today, 02:34
Joined
May 30, 2008
Messages
32
You are wonderful that worked.
Thank you, why did it need quotes for future reference.
 

chergh

blah
Local time
Today, 10:34
Joined
Jun 15, 2004
Messages
1,414
Because you need to pass the datasource for the recordset as a string and strings need quotes.
 

namliam

The Mailman - AWF VIP
Local time
Today, 11:34
Joined
Aug 11, 2003
Messages
11,695
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

Top Bottom