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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform visible based content

Status
Not open for further replies.

greenter

MIS
Nov 3, 2001
11
US
every record in the main form will have linking data in the subform. What is an easy way to set the subform to not be visible if there is no data to display? Thanks!
 
In the on_current event of your main form, you could use somthing like the following:

'Being Sub
Dim cnn as ADODB.Connection, rst as ADODB.Recordset

Set cnn = CurrentProject.Connection
Set rst = New ADODB.Recordset

rst.Open("SELECT * FROM [SubformRecordSource]"),cnn, adOpenStatic

If rst.RecordCount > 0 Then
Me.SubformName.Visible = True
Else
Me.SubformName.Visible = False
End If

set rst = nothing
set cnn = nothing

'End Sub

You should note that any processing for the subform will still occur, even if it is not visible... James Goodman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top