Results 1 to 5 of 5

Thread: flexgrid

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    Tennessee
    Posts
    279

    Question

    How can I enter the parameters for a search on one form, run an SQL query, and pull up another form with a flexgrid displaying the results of the search. I'm confused as to how to transfer the results of the search to the other form and populate the grid (10 fields per record) one record at a time.I would appreciate any help.
    A cynic knows the price of everything but the value of nothing.

  2. #2
    Hyperactive Member
    Join Date
    Oct 2000
    Posts
    303
    Do you know how to use the flexgrid to display
    your results? That would be the first thing to
    do. Other than that, I am not sure, but think
    you should be able to set your SQL so that
    it is global to your project. Once the user click the
    QUery form, it then does the search. Once it found
    the result, you can call the Display form (form2.show)
    to show your result.

  3. #3
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Yes, the important thing is to know how records can be displayed in the FlexGrid. Apart from that, here are a few things you might try:

    1. Declare a string variable global to your project. In your query form, set this string variable to the appropriate query string and invoke the Grid form. In the grid form, use this string variable to open a recordset and populate the grid.

    2. Declare a recordset object public to your project. In your query form, open this recordset with the appropriate SQL statement and then call the grid form, which will simply use this recordset to populate the grid.

    3. Open the recordset in your query form, then access the grid control on the grid form to populate it from the query form itself, and once the control is populated, show the grid form.

    4. Declare public variables in the grid form for all the parameters that you require. From the query form, set the values of these public variables to the parameter values accepted in the query form, and then show the grid form. In the grid form, use these variables to frame the SQL statement, open the recordset and populate the grid.

    There may be more ways, but I guess this much will be more than enough.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  4. #4
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Red face You can do this way

    I am not going to write the whole thing to get the sql query but I am just going to tell that how to get the text from the other form. Let us say that you have a text box on the form named "Form2", and you want to get the sql query from that text box in "form1".

    Dim thequery as string
    thequery = form2.controls.text1.text


    New thequery has the sql query form the textbox on form2.The name of form and textbox could be varried.

    I think that is what you were talking about!
    Baaaaaaaaah

  5. #5
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    abdul, you can access the Text1 on Form2 just by saying

    Code:
    Form2.Text1
    instead of accessing the .Controls collection of Form2.

    Your method is correct, but in real life, textboxes would be used only to get parts of the query, like which fieldnames to retrieve and so on. If a user was to write the entire query in a textbox, your approach would work fine.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

Posting Permissions

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



Click Here to Expand Forum to Full Width