Full Version: Subform Visibility.
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
dustycat
Good afternoon..

I have a main form/subform that I want to change to do the following.

based on the selection in either a combobox or by a parameter, display the subform if a record exists in the associated table or a message saying no record exists and subform is not visible

Any pointers would be great


Thanks



Alan_G
Hi

You could use DCount() to test for the existence or not of a record, and toggle the subforms visible property depending on the outcome

CODE
If DCount("*","YourTable","YourCriteria") = 0 Then
   Msgbox "No such record"
   Me.NameOfSubformControl.Visible = False
   Else
   Me.NameOfSubformControl.Visible = True
End If
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.