Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2009
    Location
    Berkshire, UK
    Posts
    30

    Unanswered: Make button visible when subform is empty

    I have a button called cmdDelete on a main form which is invisible by default.

    I want to make the button visible when the subform sbfAllotmentsByTenant contains no records.

    I thought this might do it, but it doesn't work and I don't know which main form event to put it in. Any advice please?

    Mike

    Code:
    If Me.sbfAllotmentsByTenant.Form.RecordsetClone.RecordCount = 0 Then
             Me.cmdDelete.Visible = True
        Else
        End If

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Try:
    Code:
    If Me.<Subform>.Recordset.RecordCount = 0 Then
    Have a nice day!

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Or maybe on the subform itself (not sure if this would work though)...

    If me.recordcount = 0 then
    Forms!MyMainFormName!cmdDelete.visible = false
    else
    Forms!MyMainFormName!cmdDelete.visible = true
    end if
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Nov 2009
    Location
    Berkshire, UK
    Posts
    30
    Thanks for the suggestions. I tried a combination of the two and had some limited success, but it wouldn't operate reliably so I redesigned the form and did it another way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •