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

Subform Data

Status
Not open for further replies.

fabby1

Technical User
Mar 9, 2004
206
0
0
GB
Hi

I have a Main form and a Subform linked together via the staffno

On the main form there is a combobox that the user selects an employee name from.

This then populates the Main form with details like Name Address etc.

The subform is then populated with his sickness records.

What I would like to know is.

How do I if the user has no sickness in the subform hide it.

this is the following code on the AfterUpdate Combo box

Code:
Private Sub cmb_Search_AfterUpdate()
    Dim rs As Object
    
    G_STAFFNO = Me.cmb_Search.Value

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[STAFFNO] = '" & Me![cmb_Search] & "'"
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark

    G_STAFFNO = Me.cmb_Search
    G_EForename = Me.cmb_Search.Column(1)
    G_ESurname = Me.cmb_Search.Column(0)
    G_EName = Me.cmb_Search.Column(1) & " " & Me.cmb_Search.Column(0)
End Sub

What happens at the moment is that if the user has no sickness records it goes to the first record.

Thanks

Phil
 
Try something like

With Me![SubformName].Form
.Visible = (.RecordsetClone.RecordCount > 0)
End With

Regards

Peachmelba
 
Peach

Thanks for that works Great

Tar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top