Create graph for database table

Posted on 2002-04-04
Last Modified: 2012-06-21
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.
Question by:humbk2002
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 6918383
there is VB code for    GraphLite  (better than ms graph)
of course it is not full job but hope it helps

Accepted Solution

Bahnass earned 37 total points
ID: 6918393

Author Comment

ID: 6924791
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\FinalProject(ExpensesMonitoringSystem).mdb")
Set RS = DB.OpenRecordset("qryExpenditure_transactions")
 numbExpenseCategory = 15
 maxExpensePayment = 0
Open "Z:\Project\FinalProject(ExpensesMonitoringSystem).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
 expGraph.Scale (-1, 1.2 * maxExpenseCategory)-(numbExpenseCategory + 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)-(tickfactor, maxExpensePayment)
 expGraph.CurrentX = -tickfactor - lblwidth
 expGraph.CurrentY = maxExpensePayment - lblheight / 2
 expGraph.Prit lbl
 End Function

Expert Comment

ID: 7017043
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.
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.

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.

*****  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 
POINTS FOR EXPERTS awaiting comments are listed in the link below
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.
Moderator @ Experts Exchange
LVL 49

Expert Comment

ID: 7642926
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

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question