Solved

Error 424 "Object Required" - Please Help

Posted on 2006-10-19
5
255 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
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 33

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 33

Expert Comment

by:Mike Eghtebas
ID: 17771819
or

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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now