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

Graph properties don't "take" first time form is opened

Status
Not open for further replies.

N2Life

Programmer
Dec 21, 2002
90
US
Reference thread181-821399. A similar question was posted in Nov of 2004, with no responses.

I am using Windows XP, Access 2000. I have a graph (chart) on a form. There is a combo-box in which you select what series to graph. Doing so should cause the title of the graph to change, as well as the scale of the graph.

The first time I open the program and go to this form and click on a series, those updates do not take place. The data points are graphed correctly, but the title and scale do not update. I can then click on the same choice in the combo-box again and everything updates properly. Has anyone else ever encountered this and solved it?
 
You might want to requery the graph control following your updates to the combo box.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Tried all sorts of things, obvious and not - requery; refresh; set title to a single space, then set to the real title - with no success. The beast just seems to need a first flush to get warmed up.
 
What was your requery code?

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
The graph object is named Graph_Order. The code I tried for requerying (without success):

[Graph_Order].Requery

Even added this code after that:

Me.Refresh
Me.Repaint

(in desperation).

Thank you for taking up my question.
 
I'm not at all sure where your original title on the chart came from and why you would expect it to change. This is normally not "bound" to any data.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
True. It is not bound. But you can modify it with VBA (at least eventually). My combo-box is a list of parts for which I graph some data. I want the title on the graph to include the name of the part. I finally just put that information in the header of the form, for lack of any other solution. (I hate these compromises with Access.) But now I have the issue of the Scale of the vertical axis. Again, I can do this, but not the first time the program is opened and this form is loaded.

My only issue here is "Why does my code not work the FIRST time?" After that first hiccup, I can click on anything in the combo-box and everything works fine.
 
I don't see any code that sets any properties in what you have posted.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Hi N2Life

I had a very similar problem. As I understand it, it's to do with the chart being drawn before it's actually got all the data. The work around is to run a small loop to delay the formatting process and allow all the data to be processed.

try this -

Use a DoEvents Loop
1. Create a new module.
2. Paste or type the following function into the new module:
3. Function TestProc()
4. Dim i As Integer
5. For i = 1 To 5
6. DoEvents
7. Next i
8. End Function

Because this behavior is related to timing, you may have to increase the number of iterations through the loop. Because the number of iterations that must be performed is variable, a maximum value is not provided. The number of iterations is dependent on such things as the complexity of the report, the complexity of the graph, or the number of records.

9. Save and then close the module.
10. Open your report in Design view.
11. Open the Properties window for the section that contains the graph object, and then click the Events tab.
12. For the On Format event, call the TestProc procedure
that you created in step 2.

Hope it helps
 
Duane, you asked only for my requery code. There is plenty more I did not include. The code that sets properties works. Just trying to keep my question narrowly focused.

SmallTime, I will try give that a try.

My thanks to both of you.
 
Problem is resolved. (SmallTime, your suggestion was for a report, but my problem was in a form - where there is no On Format event.)

Problem description:
My form opened with a combo-box in which nothing was selected. A related graph on the form was hidden until user clicked on something in the combo-box; the On Click event made the graph visible and updated it. Problem was that the very first selection would not update either the graph title or the y-axis scale from what they had been when the form was last opened; data were graphed properly however. But subsequent selections in the combo-box always produced fully updated graphs.

Resolution of problem:
I re-coded so that when the form opens, the first choice in the combo-box is automatically selected and the graph is drawn at once. Graph is never hidden. Everything is updated properly now. I don't know why the first approach did not work. I think it should have. But in Access there are usually at least 2, often 3, ways of getting some things done. I am happy with this work-around.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top