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

How can I grey out a Cmd Button if no records are present? 1

Status
Not open for further replies.

CliffSP

IS-IT--Management
Jul 22, 2005
30
Hi all

I have a subform and a Cmd button at the bottom that will Preview a filtered report. Is it possible, and how, to grey (disable) this button out if there are no records in the subform?

Many thanks


Cliff
 
Possibly something like:

If Forms![MainFormName]![SubFormName].Form.RecordsetClone.RecordCount > 0 Then

MyButton.Enabled = True

Else

MyButton.Enabled = False

End If
 
Thanks for the reply...

Unfortunately it doesn't work for me - the button stays live.

I've substituted MainFormName & SubFormName for the actual names and substituted MyButton for the control name.

Was this the right thing to do?

TIA
 
Yes, that was correct.

Where did you put this code - on the OnCurrent Event of the Main Form?
 
How are ya CliffSP . . .

In the [blue]OnCurrent[/blue] event of the subform:
Code:
[blue]Me![purple][b]ButtonName[/b][/purple].Enabled = (Me.RecordsetClone.Recordcount <> 0)[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thankyou AceMan1!

I see you are still performing up to the usual standard - many thanks!

Cliff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top