How to refer to a query from VBA?

  • Thread starter Thread starter Richard Black
  • Start date Start date
R

Richard Black

Hi,

I'm trying to write some code to alter the titles of a pivot chart, but I
can't work out the syntax for refering to the query in code from a form

eg:

[code in myForm]

Private Sub Command19_Click()

With AllQueries.myQuery.Axes
.HasTitle = Not .HasTitle 'toggles axis title

End With

End Sub

[end code]

TIA,

Richard
--
 
Richard,

Since Pivot Charts are a part of MS Excel, you might repost the question
over in either:

microsoft.public.excel.charting
or
microsoft.public.excel.programming


Sincerely,

Chris O.
 
Chris,

Thanks for the reply. I am attempting to refer to the pivot charts that can
be made within Access 2002 from a query. All I really want to know is what
group/collection they would be in - the equivalent of Forms![myForm] - so
that I can refer to it in VBA. The Excel pivot charts do not seem to share
the same syntax.

TIA,

Richard
 
Richard-

Where is the Pivot Chart? Is it a form that's a subform to the one running
this code? If it's a form, you can find many of the properties you might
want to modify on the fly as part of the form's ChartSpace object - check it
out in the Object Browser. For example, to toggle on the Title in the chart
stored in a subform control called fsubChart, you could in the outer form
write:

Me.fsubChart.Form.ChartSpace.HasChartSpaceTitle = True

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 
Excellent, thank you - that worked great. The chart is indeed in a subform.
I'm fairly new at this programming thing and am basically crossing each
bridge as I come to it. Unsurprisingly, I could find absolutely no
reference to this problem in the Access help file, or on the MS website... I
noticed you have some Access tips on your website and was wondering if you
could recommend any resources presented along the lines of "if you want to
do [this], you need to use [this term]".

Thanks again,

Richard
 
Access Help sucks in 2000 - 2003. One of the best resources, believe it or
not, is the Object Browser in the VB Editor. I didn't have a clue what the
syntax might be until I went hunting through the properties of the Form
object. ChartSpace looked likely, so I looked at all the properties/methods
for that and found HasChartSpaceTitle. I happened to have a sample chart
form lying around so I opened it and tried modifying that property in the
Immediate Window. Bingo.

Another trick is to go to the Immediate Window, type in a keyword you think
is relevant, highlight it, and press F1. Voila - Help on the ChartSpace
object!

As for "how to" references -- I'd certainly be happy if you considered my
Inside Out book, but your best bet is to go spend an afternoon in a
brick-and-mortar bookstore that has a good computer book section and a handy
easy chair. Grab some Access books off the shelf and see which of them
"talk" to you. Most serious developers I know have an entire shelf full of
books. (I do - including Roger Jennings' "Using", Cary Prague's "Bible",
and Getz/Litwin "Developers Handbook".) There's no way any one author can
cover it all in 1,000-1,500 pages.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 
Back
Top