Sub-forms

PR2AledE

Registered User.
Local time
Today, 11:25
Joined
Mar 21, 2003
Messages
16
How do I hide a sub-form if the number records to be displayed in it is zero i.e how do I stop blank sub-forms being displayed?
 
Hello

Go to the open event of the form. In form properties uner event choose code builder


make sure you have the dao 3.51 (access97) or dao3.6(access 2000) object libraries (on the menu bar in the code window select tools then references)

paste this code into the form open

when the form opens the subform will disappear if there are no records to be displayes


Dim rst As DAO.Recordset

'change the name of the subform to yours
' me = main form
' SELECT_HOSP_SPELL_FRM = sub form

Set rst = Me.SELECT_HOSP_SPELL_FRM.Form.RecordsetClone

if rst.RecordCount = 0 then
Me.SELECT_HOSP_SPELL_FRM.Form.Visible = False
end if

set rst = nothing

Chris
 

Users who are viewing this thread

Back
Top Bottom