Consulting

Results 1 to 9 of 9

Thread: Solved: List grid solution for a user form

  1. #1
    VBAX Regular
    Joined
    Jan 2010
    Posts
    13
    Location

    Solved: List grid solution for a user form

    Hello everybody.

    I am writing a code in Excel which allows user to retrieve invoice data from our SQL server. I am retrieving the data through adodb connection.

    I have managed to import required data from SQL to excel, now I would like to take a further step.

    I want to create a user form which enables the user to query the required invoice records from server, with specifying customer code, customer name, date or invoice number. I have no problem writing the code which will execute the query, but I couldn't find any solution to show the query results on the form.

    Let me give you an example. Let's say I want to retrieve an invoice from the server. This invoice has been issued sometime between 12nd and 16th of this month. I know the customer name but I don't have the invoice number. When I query the server for invoices between 12nd and 16th, I should see the results in the form, let's say, in a grid, with columns such as customer name, customer code, invoice date, invoice number etc. and when I click (or double click) on the relative line, I should be able to start another query which will import all data related to that invoice. Do you have any idea how (or if) I can manage that? Thanks in advance for any answer!

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    We have an sql forum. Would you like your request moved to that forum?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    VBAX Regular
    Joined
    Jan 2010
    Posts
    13
    Location
    Quote Originally Posted by lucas
    We have an sql forum. Would you like your request moved to that forum?
    Good idea, since I am working in Excel I thought Excel would be a more suitable choice, I did not figured the problem is more SQL-releated. Thanks for advice and I apologize for inconvenience.

    Forgive my ignorance, I am quite new at the forum, how do I request to move it?

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I would put the details in a listbox, simpler to work with than a grid, and then use the selected item to re-query.

    You can just drop the recordset into an arry (ary = RS.GetRows) and then populate the listbox with that array (ListBox1.List = APplication.Transpose(ary)). Make sure you set the columncounts property.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Regular
    Joined
    Jan 2010
    Posts
    13
    Location
    Quote Originally Posted by xld
    I would put the details in a listbox, simpler to work with than a grid, and then use the selected item to re-query.

    You can just drop the recordset into an arry (ary = RS.GetRows) and then populate the listbox with that array (ListBox1.List = APplication.Transpose(ary)). Make sure you set the columncounts property.
    I was planing to do it that way, than I figured that it would be easier for user to work with a grid. Besides, I will feel myself much better if it looks like a table with all the details and headers. Is there a way to make it work with a grid? if not, I will use a listbox anyway.

  6. #6
    VBAX Regular
    Joined
    Jan 2010
    Posts
    13
    Location
    by the way, I am developing the application in Office 2007, but it also have to work in Office 2003.

  7. #7
    VBAX Regular
    Joined
    Jan 2010
    Posts
    13
    Location
    I have used a listbox, thanks to all for helping.

  8. #8
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    I see this has been marked as solved, but I wonder why the OP didn't just use SQL Server Report Services as the query with the option to export the results to Excel? .02 Stan

  9. #9
    VBAX Regular
    Joined
    Jan 2010
    Posts
    13
    Location
    Actually, I am very new on programming and don't know all the technologies / techniques, I am aware that there is something called "SQL Report Services" but I don't know what kind of requirements it can answer to.

    Besides, what I am trying to do is creating a very simple userform on excel for office use. This will be used by employees that barely can use excel. I cannot expect them to start a query to SQL server and import required data to Excel(imagine how hard my life is ) For myself, it is better to query data via external data wizard but other people on organization needs a simpler (way simpler) solution. That is why I decided to code something like this.

    Anyway, if you have any idea that makes my life easier I really would appreciate it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •