humbk2002
asked on
Create graph for database table
I need a code that will be able to create a graph for the contents of database table maybe with the following fileds:ExpenseCategory and Amount,this graph should show the titile,the table fileds,and their figures also.I want different code for bar chart and a line chart.I have only 37 points available for a correct answer.Thus code has to basic,that is catering for extension of the table fields,whenever need arose.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My friend that code is not easy,it needs a lot of things.I have a code below,that generate a bar graph for items in a database query,this graph goes to a query and select two fields in that query and displays the information.This information is already stored in the database.This function is caled in a different sub procedure,but it gives me a complie error like this:
"Sub or funtion not defined"
Public Function BarChartDraw()
Dim numbExpenseCategory As Integer, maxExpensePayment As Single, i As Integer
Dim lbl As String, lblwidth As Single, lblheight As Single
Dim tickfactor As Single
Set DB = OpenDatabase("Z:\Project\F inalProjec t(Expenses Monitoring System).md b")
Set RS = DB.OpenRecordset("qryExpen diture_tra nsactions" )
numbExpenseCategory = 15
maxExpensePayment = 0
Open "Z:\Project\FinalProject(E xpensesMon itoringSys tem).mdb" For Input As DB
For i = 1 To numbExpenseCategory
Input #1, ExpenseCategory(i), Amount(i)
If ExpenseCategory(i) > maxExpensePayment Then
maxExpensePayment = ExpenseCategory(i)
End If
Next i
Screen.MousePointer = vbHourglass
RS.Update
expGraph.Scale (-1, 1.2 * maxExpenseCategory)-(numbE xpenseCate gory + 1, -0.2 * maxExpensePayment)
expGraph.Line (-1, 0)-(numbExpenseCategory + 1, 0)
expGraph.Line (0, -0.1 * maxExpensePayment)-(0, 1.2 * maxExpensePayment)
For i = 1 To maxExpenseCategory
expGraph.Line (i - 0.2, Amount(i))-(i + 0.2, 0), , BF
Next i
expGraph.Line (i, ExpenseCategory(i))-(i + 1, ExpenseCategory(i + 1))
End If
expGraph.Circle (i, ExpenseCategory(i)), 0.01 * maxExpenseCategory
Next i
expGraph.CurrentX = -0.5
expGraph.CurrentY = -0.1 * maxExpenseCategory
expGraph.Print "Expense Categories "
expGraph.CurrentX = 0.5
expGraph.CurrentY = 1.2 * maxExpenseCategory
expGraph.Print "Total Expenditure Transactions Made"
For i = 1 To maxExpenseCategory
lbl = Label(i)
lblwidth = expGraph.TextWidth(lbl)
tickfactor = 0.02 * maxExpenseCategory
expGraph.Line (i, -tickfactor)-(i, tickfactor)
expGraph.CurrentX = i - lblwidth / 2
expGraph.CurrentY = -tickfactor
expGraph.Print lbl
Next i
lbl = Str(maxExpenseCategory)
lblwidth = expGraph.TextWidth(lbl)
lblheight = expGraph.TextHeight(lbl)
tickfactor = 0.02 * maxExpenseCategory
expGraph.Line (-tickfactor, maxExpensePayment)-(tickfa ctor, maxExpensePayment)
expGraph.CurrentX = -tickfactor - lblwidth
expGraph.CurrentY = maxExpensePayment - lblheight / 2
expGraph.Prit lbl
End Function
"Sub or funtion not defined"
Public Function BarChartDraw()
Dim numbExpenseCategory As Integer, maxExpensePayment As Single, i As Integer
Dim lbl As String, lblwidth As Single, lblheight As Single
Dim tickfactor As Single
Set DB = OpenDatabase("Z:\Project\F
Set RS = DB.OpenRecordset("qryExpen
numbExpenseCategory = 15
maxExpensePayment = 0
Open "Z:\Project\FinalProject(E
For i = 1 To numbExpenseCategory
Input #1, ExpenseCategory(i), Amount(i)
If ExpenseCategory(i) > maxExpensePayment Then
maxExpensePayment = ExpenseCategory(i)
End If
Next i
Screen.MousePointer = vbHourglass
RS.Update
expGraph.Scale (-1, 1.2 * maxExpenseCategory)-(numbE
expGraph.Line (-1, 0)-(numbExpenseCategory + 1, 0)
expGraph.Line (0, -0.1 * maxExpensePayment)-(0, 1.2 * maxExpensePayment)
For i = 1 To maxExpenseCategory
expGraph.Line (i - 0.2, Amount(i))-(i + 0.2, 0), , BF
Next i
expGraph.Line (i, ExpenseCategory(i))-(i + 1, ExpenseCategory(i + 1))
End If
expGraph.Circle (i, ExpenseCategory(i)), 0.01 * maxExpenseCategory
Next i
expGraph.CurrentX = -0.5
expGraph.CurrentY = -0.1 * maxExpenseCategory
expGraph.Print "Expense Categories "
expGraph.CurrentX = 0.5
expGraph.CurrentY = 1.2 * maxExpenseCategory
expGraph.Print "Total Expenditure Transactions Made"
For i = 1 To maxExpenseCategory
lbl = Label(i)
lblwidth = expGraph.TextWidth(lbl)
tickfactor = 0.02 * maxExpenseCategory
expGraph.Line (i, -tickfactor)-(i, tickfactor)
expGraph.CurrentX = i - lblwidth / 2
expGraph.CurrentY = -tickfactor
expGraph.Print lbl
Next i
lbl = Str(maxExpenseCategory)
lblwidth = expGraph.TextWidth(lbl)
lblheight = expGraph.TextHeight(lbl)
tickfactor = 0.02 * maxExpenseCategory
expGraph.Line (-tickfactor, maxExpensePayment)-(tickfa
expGraph.CurrentX = -tickfactor - lblwidth
expGraph.CurrentY = maxExpensePayment - lblheight / 2
expGraph.Prit lbl
End Function
10 open questions, many are far below the minimum for easy questions of 50 points. The maximum per question is 500 points. ADMINISTRATION WILL BE CONTACTING YOU SHORTLY. Moderators Computer101, Netminder or Mindphaser will return to finalize these if they are still open in 7 days. Experts, please post closing recommendations before that time.
Below are your open questions as of today. Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response. This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database. If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
--> Post comments for expert of your intention to delete and why
--> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.
For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process. https://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp
Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.
Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added. When you grade the question less than an A, please comment as to why. This helps all involved, as well as others who may access this item in the future. PLEASE DO NOT AWARD POINTS TO ME.
To view your open questions, please click the following link(s) and keep them all current with updates.
https://www.experts-exchange.com/questions/Q.20283897.html
https://www.experts-exchange.com/questions/Q.20273817.html
https://www.experts-exchange.com/questions/Q.20274315.html
https://www.experts-exchange.com/questions/Q.20275778.html
https://www.experts-exchange.com/questions/Q.20277334.html
https://www.experts-exchange.com/questions/Q.20278207.html
https://www.experts-exchange.com/questions/Q.20281536.html
https://www.experts-exchange.com/questions/Q.20284857.html
https://www.experts-exchange.com/questions/Q.20285984.html
https://www.experts-exchange.com/questions/Q.20287484.html
***** E X P E R T S P L E A S E ****** Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
POINTS FOR EXPERTS awaiting comments are listed in the link below
https://www.experts-exchange.com/commspt/Q.20277028.html
Moderators will finalize this question if in @7 days Asker has not responded. This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
Thanks everyone.
Moondancer
Moderator @ Experts Exchange
Below are your open questions as of today. Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response. This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database. If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
--> Post comments for expert of your intention to delete and why
--> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.
For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process. https://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp
Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.
Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added. When you grade the question less than an A, please comment as to why. This helps all involved, as well as others who may access this item in the future. PLEASE DO NOT AWARD POINTS TO ME.
To view your open questions, please click the following link(s) and keep them all current with updates.
https://www.experts-exchange.com/questions/Q.20283897.html
https://www.experts-exchange.com/questions/Q.20273817.html
https://www.experts-exchange.com/questions/Q.20274315.html
https://www.experts-exchange.com/questions/Q.20275778.html
https://www.experts-exchange.com/questions/Q.20277334.html
https://www.experts-exchange.com/questions/Q.20278207.html
https://www.experts-exchange.com/questions/Q.20281536.html
https://www.experts-exchange.com/questions/Q.20284857.html
https://www.experts-exchange.com/questions/Q.20285984.html
https://www.experts-exchange.com/questions/Q.20287484.html
***** E X P E R T S P L E A S E ****** Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
POINTS FOR EXPERTS awaiting comments are listed in the link below
https://www.experts-exchange.com/commspt/Q.20277028.html
Moderators will finalize this question if in @7 days Asker has not responded. This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
Thanks everyone.
Moondancer
Moderator @ Experts Exchange
Hi humbk2002,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept Bahnass's comment(s) as an answer.
humbk2002, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept Bahnass's comment(s) as an answer.
humbk2002, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
www.vbsquare.com
there is VB code for GraphLite (better than ms graph)
of course it is not full job but hope it helps