Solved

Error 424 "Object Required" - Please Help

Posted on 2006-10-19
5
260 Views
Last Modified: 2012-08-13
Hello experts,

I'm getting an error while looping through records in a table and can not figure out why.

==============================================================================

Private Sub txt_InPut_AfterUpdate()

    If IsNull(txt_InPut.Value) = False Then

    DoCmd.RunSQL ("INSERT INTO tbl_Main (txt_Content) VALUES ('" & txt_InPut.Value & "');")

    If txt_OutPut.Value <> "" Then txt_OutPut.Value = txt_OutPut.Value & vbCrLf
    txt_OutPut.Value = txt_OutPut.Value & txt_InPut.Value
    txt_InPut.Value = ""
    End If
   
Dim rst As DAO.Recordset
Dim x As String
Set rst = CurrentDb.OpenRecordset("SELECT txt_Content FROM tbl_Main")

rst.MoveFirst

Do Until rst.EOF
x = x & tbl_Main!txt_Content     <--------------------------------------------------------------THE ERROR HAPPENS HERE!
Me.txt_OutPut = vbCrLf & x
rst.MoveNext
Loop

Me.txt_InPut = ""

rst.Close
     
Requery
     
End Sub

==============================================================================
0
Comment
Question by:donniedarko801
[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
5 Comments
 
LVL 34

Accepted Solution

by:
flavo earned 500 total points
ID: 17770501
>x = x & tbl_Main!txt_Content  

Try:
x = x & rst!txt_Content  

Dave
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 17770503
Having already opened the recordset (you did so for a reason) you use that surely?
x = x & rst!txt_Content    
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 17771174
to avoid future errors, that is if txt_Content might be left blank:

x = x & Nz(rst!txt_Content,"tbd")   'to be determined for string type

x = x & Nz(rst!txt_Content,0)    ' for number type

mike
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17771591
Other lads have sorted out your error

But...

Your loop is building x

I guess then u dont want to keep showing the building of x so I suggest u move this line out of the loop

Me.txt_OutPut = vbCrLf & x


0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 17771819
or

x = x & Nz(rst!txt_Content,"tbd")  & "; "
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

705 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