HELP - Display chart in a form, only if have record

luigen

New member
Local time
Today, 19:33
Joined
Apr 2, 2007
Messages
9
Hi. I have a form with a chart inside.
This one is populated with a query.
In some case, the result of the query is no record.
Can i suppress the view of chart in this case?
If yes, how?
Some example are apreciated.

Thanks

Luigi
 
On the Open Event of the form why don't you check the Record Count of the query. If it brings back 0 why not set the Chart Visible Property to False.
 
Thanks for reply.
Can I have an example. I'm a newbe user of Access
Thanks

Luigi
 
A simple and quick way is:

Private Sub Form_Open(Cancel As Integer)

'Check number of records in Record Source of Chart
If DCount("[Field Name]", "Table/Query Name") > 0 Then

MSChartName.Visible = True

Else

'Don't display chart
MSChartName.Visible = False

End If

End Sub

------------------------

To be honest though, if the form is only showing a chart relating to a button the user presses, it would be better to do this onClick Event on the button:

Private Sub CommandButtonName_Click()

'Check if any data returned from Query
If DCount("[Field Name]", "Table/Query Name") > 0 Then

'Open form with Chart commands here

Else

'No need to open form
Msgbox "There are no records to display", vbOKOnly + vbCritical, "Warning"

End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom