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

hide a button on form until needed

Status
Not open for further replies.

doc6

MIS
Feb 12, 2000
8
US
I have a master and a sub form with two different tables in each. The tables are common to each other by a key field. The sub form is called by clicking on the appropriate button that I created by the wizard. The problem is that I only want the button to be visible when a record in the master matches a record in the sub form. The subform uses a query to find the matching record. So in short I only want the user to see and click on the button when a matching record resides in the subform table. Thanks!
 
Test the subform for a record count<br>
Like so<br>
Private Sub Form_Current()<br>
' If no records match criteria, Hide button.<br>
If Me![Mailing List subform].Form.RecordsetClone.RecordCount = 0 Then<br>
'Hide Command button<br>
Command14.Visible = False<br>
Else<br>
'Show Command button<br>
Command14.Visible = True<br>
End If<br>
End Sub<br>
<br>
--------------------<br>
Put this code in the Main forms On_current event.<br>
<br>
I just tested it and it works great...<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top