Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display text from a field on a form

Status
Not open for further replies.

Hawkide

Technical User
Oct 8, 2003
159
US
Access 97

I have a textbox on a report that displays text from a field on a form (frmSubForm). That field gets its text from a table called tblComments. The actual record from which to display, is determined from the RecordSource of frmSubForm.

The textbox on the report has the following control source:

=[Forms]![frmMain]![frmSubForm]![Comment]

This works nicely whenever a there is a record in tblComments, but if there is no record, it returns #Error

I would prefer that the textbox just displays nothing as opposed to #Error. Any ideas?
 
In the controlsource of the textbox on the report put something like this:

=IIf(IsNull([Forms]![frmMain]![frmSubForm]![Comment]
),"",[Forms]![frmMain]![frmSubForm]![Comment]
)

or you could do a count of records in the tblComments table...

=IIf(DCount("*","tblComments")=0,"",Forms!Form12!comment.Value)


Hope this helps.
 
oops, the second part of my previous post should read...

=IIf(DCount("*","tblComments")=0,"",[Forms]![frmMain]![frmSubForm]![Comment]
)

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top