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

runtime error 1004...woes

Status
Not open for further replies.

Ollie71

Technical User
Jun 4, 2008
20
AU
Hello its me again with another strange one. I have a form that displays a big graph of individual elements, that the user selects off a pull down menu.

When selected, several functions are called to set the graphs source with the right sql to get the data for the graph.

The second function sets the y axis to the highest value in the data and the third requeries and sets the graph to visible.

When I select the element I am getting the following the error message:
"Run time error '1004':
Unable to set the maximum property of the Axes class"

this is the function code that is supposed to do it
Function SetAxisLimit()

Forms!LabGraphElement![MxXCtl] = MxX
Forms!LabGraphElement![MxYCtl] = MxY

MaxYaxis = DMax("[Elements]", "Qry_GetGraphRange", "[ElementId] =""" & [Forms]![LabGraphElement]![SelectElement] & """")
Forms!LabGraphElement![GraphMain].Object.Application.Chart.Axes(2).MaximumScale = MaxYaxis

End Function

I had another problem and was told here to properly normalise my tables, so this is a direct copy of the old database where this graph works perfectly. Since normalising the database required spliting the tables up I had to redo all the queries and forms. I have set this new version of the database to have exactly the same references as the old version, which i thought may have been the problem.

To make matters more confusing, when I get this error I can debug or end it. If I push end, and select the element again, it will work, even setting the axes limit.

when the form is opened the graph is activated and then set invisible, and waits for the selection then fails, but only on the first time, which I dont at all understand.

Anyone have any clue to why I get this error and why if I end the error dialog and re-select it suddenly works perfectly?
 
I am guessing that the following line is highlighted in Yellow when it errors...

Code:
Forms!LabGraphElement![GraphMain].Object.Application.Chart.Axes(2).MaximumScale = MaxYaxis

What is the value MaxYaxis when it fails?

Can't say I know much about graphs but it sounds like a timing issue since it works the second time... The other questions would be when do you call your procedure (on click)?

I'm hoping to at least have enough information available so a graph guru can spot the issue.
 
Yes you are correct that line is highlighted. Last time I ran it, MaxYaxis = 3

The proceedure is called on the after update of the combo selection box. Its one of 3 called.

The first Drawgraph() simply sets the rowsource of the graph with a select statement that incorporates the user selection.

The second is SetAxisLimit() which handles the above and where it fails

the third is ShowGraph() where I requery and set the graph to visible.

Wierd that it works in the old database with more complex table structure and will work if you make the selection again in this one, but always fails the first time. Anyone got any suggestions or ideas?
 
It seems like the recordsource is not populated on the first pass.... Is there a requery or refresh that you can do after you set the recordsource?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top