populate chart category from a combobox


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 1 of 2 12 LastLast
Results 1 to 15 of 28

Thread: populate chart category from a combobox

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Posts
    106

    populate chart category from a combobox

    Hello
    Iím using VB 6 as a front end to Access 03 database to populate the MSChart control.
    I have a combobox for defect categories. I would like to populate the chart with a single category selected from the combobox.

    Not sure what to put in place of the * as shown in the statement below. I would like to display the date (Weeks) and the category with the number of defects.
    Code:
    Private Sub CategoryView()
            
        '  Display the category of chart data
        Set cmd.ActiveConnection = cn
        cmd.CommandText = "SELECT * FROM tbliface WHERE [Weeks] = '" & cboCategory.Text & "'" _
        & " ORDER BY [Weeks]"
    thanks for any help
    Steve

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    What are the columns in your database? It's impossible for us to guess. ;-)
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Exactly.

    First, there is seldom, if ever, a reason to do a SELECT * - the field names that you want should always be listed out, in my opinion.

    And, the field name that holds your categories is what you are after.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  4. #4
    Join Date
    Sep 2005
    Posts
    106
    Yes, sorry for the confusion. The fields are...
    Weeks Analyzer Humphrey Accumulator Pump Regulator Card NDF Solenoid.

    This case definitely don't want all the fields returned. I guess I get lazy and use * when I want to cut down on the code.

    Is this even in the ballpark?...
    Code:
    cmd.CommandText = "SELECT '" & cboCategory.Text & "' FROM tbliface WHERE [Weeks] = '" & cboCategory.Text & "'" _
        & " ORDER BY [Weeks]"
    I want to return only two fields keying on the selection from the cboCategory combobox. The date field and the category chosen. Currently this isn't returning anything.

    Steve

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    What is in cboCategory?

    When you actually run the code, what does the query look like?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  6. #6
    Join Date
    Sep 2005
    Posts
    106
    These are in the drop down...
    Analyzer Humphrey Accumulator Pump Regulator Card NDF Solenoid

    When I set a breakpoint just after the cmd.CommandText statement and run this I cursor over '" & cboCategory.Text & "' and get the choice made from the combobox. But nothing shows in Weeks when cursored over.

    I think (hope) I'm on the right track.

    Steve

  7. #7
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    So, give me a "fer instance".....what would the actual query going back to the database look like?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  8. #8
    Join Date
    Sep 2005
    Posts
    106
    I changed the query to...
    Code:
    cmd.CommandText = "SELECT '" & cboCategory.Text & "' FROM tbliface & " ORDER BY [Weeks]"
    This seems to make more sense since I want to return all selected defects from category and return ordered by Weeks.

    the rs.recordset shows it finds 11 records which sounds about right but it errors with my error handler routine message.

    Enclosed is the attachment.
    Attached Files Attached Files

  9. #9
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    And, just in case I will want to take a look at what you currently have, in addition to answering my last question, you might as well zip up what you currently have and attach it.

    I may not need it, but, if I do, it will save time.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  10. #10
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Ok, I looked back through this thread and if you posted it already, I couldn't find it.

    Errors are good (sometimes )....they provide a starting point. What is the error that you are getting?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  11. #11
    Join Date
    Sep 2005
    Posts
    106
    the error is...
    "You must choose a valid category" This is my error handler.
    Then I get a blank chart

  12. #12
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Remove your error trapping so that it will generate a runtime error, and tell me what that error is.

    (BTW: Never add error handling until you are pretty sure there are no more errors. I know that sounds strange, but it is a general rule of thumb. While developing, you want errors to occur, in their natural habitate, so you can fix them. Once you have all of the errors, that you know about fixed, then add your error handling to deal with the errors you don't know about.)
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  13. #13
    Join Date
    Sep 2005
    Posts
    106
    Sounds like good advice to me..
    There is no error without the err handler just a blank chart control.
    So maybe I'm not displaying it correctly.

    On my way home I'll check this further in a while
    Thanks for the help!

  14. #14
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Let me know what you find and where you are with this.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  15. #15
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    I wouldn't think that a field named Weeks would contain category names. Try something like:

    "SELECT '" & cboCategory.Text & "' FROM tbliface WHERE [Weeks] BETWEEN #2/1/2008# AND #2/29/2008#"

    Assuming that Weeks contains dates, that will return all the selected category values for the month of February.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Replies: 6
    Last Post: 09-06-2013, 04:44 AM
  2. VS2005 combobox and databinding issues
    By subrama6 in forum .NET
    Replies: 4
    Last Post: 02-13-2008, 10:19 AM
  3. Replies: 1
    Last Post: 08-28-2006, 07:51 PM
  4. msChart don't display xY chart
    By joni in forum VB Classic
    Replies: 0
    Last Post: 07-13-2000, 06:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center