Solved

Error 424 "Object Required" - Please Help

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

773 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