Show tabs and subforms in tabs only if data exists

emorris1000

Registered User.
Local time
Today, 15:15
Joined
Feb 22, 2011
Messages
125
I'm trying to clean up a form a bit and have it only show certain subforms/graphs if the data exists. I already have columns in a combobox query to show an "X" for if certain data appears:

Now, I know I could build another query and have some system go through and identify these things, but the easiest thing would be to reference the "X" in the columns of the combobox. Is there an easy way to reference values in the other (non-primary) columns?

Or can you think of an easy way to make these subforms only be visible when the data exists? Maybe have an on load event for the subform?
 
How about a simple DCount in the On Current Event of the form.
If the result is 0 you can make the subform invisible with:
Code:
me.mysubform.visible=false

(substitute mysubform with the actual name)

Catalina
 
I was having some difficulty figuring out how to do that. For some reason calling Me!subform![field] was yielding data even though it should have been null. I think this has to do with how it was bound to [field].

Anyways, I figured out a simple duct tape solution, so far it seems to work quite fast so I'm going to go with it:

Code:
'MS Data
If Me.cboxNB.Column(3) = "X" Then
    Me.MS_Data.Visible = True   'MS_Data is the page, column 3 shows whether there is data for this
Else
    Me.cboxNB.SetFocus
    Me.MS_Data.Visible = False
End If

Basically I figured out how to check the data in the combo box columns where I already check for existence of data with SQL and am using that to determine whether or not to turn on/off a tab. (you have to switch focus around thoguh because a page with focus can not have visible = false)
 

Users who are viewing this thread

Back
Top Bottom