Consulting

Results 1 to 13 of 13

Thread: Solved: Bound SubForm to a Query in Runtime

  1. #1
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    357
    Location

    Question Solved: Bound SubForm to a Query in Runtime


    Hi All,

    I want to know how to display data from a query to a subform.

    I have a form which aloows the users to enter the parameters. At the click of the button the query is executed by taking the parameters from the controls.

    Rather than displaying the data in a query I want to display the data in a subform(data sheet view).

    How to do so...??? Please guide.

    Regards
    Sudhir

  2. #2
    VBAX Regular
    Joined
    Jun 2009
    Location
    Dorset
    Posts
    60
    Location
    I don't think you can do this in Runtime. You need to do all your developing in the full version of Access then run it in Runtime.
    Regards
    JD
    ------------------------------------
    Software-Matters
    Dorset

  3. #3
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    357
    Location
    Matt,

    I am not able to get "You need to do all your developing in the full version of Access then run it in Runtime".

    As I am using Access 2003. Do mean that I should bound using code in VBA...???

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Matt, I think the OP may mean the Form's runtime, not a"Runtime" version of the database.

    kb, if the user is only selecting parameters for record selection purposes then it is not necessary to change the Form's record Source, if however they are selecting the Fields to be shown on the form that is a lot more difficult, because you will have to change the Form's Structure to delete any fields that were originally on it, but not in the new Query.

    So are you using the Query as a Record Filter?

  5. #5
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    357
    Location
    The user will entering the parameters for the query for record selection purposes only. They will not be be selecting the fields to be shown.

  6. #6
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Ok, then just make the query the Record Source of the Subform in Design View.
    OR use a VBA SQL Filter on the Subform.

  7. #7
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    Also, you can tie your query's parameter to an object on your Form.

    For example, say there's a combobox on your form that the user can utilize to select a value, and this value is what will be fed to the query that is your subform's record source.

    In your query (in Query Design view) you place this for the parameter's value:
    [VBA][Forms]![FormName]![ObjectName][/VBA]
    Where FormName is the form's real name and ObjectName is the combobox's name (or whatever object you are actually using). Then you need to click on Query-> Parameters- enter the exact same thing in the first box, and then select the data type that should be sent to the query.

    HTH
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  8. #8
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    Stupid double posts... *grumble*
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  9. #9
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    357
    Location
    Hi Randy,

    I apologise if I this is the second post of this kind.
    But its first from me. I serached before posting & I did not get the desired answer.

    Now I tried what u have suggested. But I want that data should be refreshed whenever user is changes the parameters. But its not happening.

    Also there is some data when I open the form for teh first time & no criteria ad been selected or entered .....!!!!!!!!!!!

    How to tackle both these issues.

    I really appreciate the your valuable time.



    Thanks
    Sudhir

  10. #10
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    I apologise if I this is the second post of this kind.
    But its first from me. I serached before posting & I did not get the desired answer.
    I wasn't talking about you- when I posted my response it appeared twice for some strange reason. That's the double-post I was reffering to. You're question is a good one

    Now I tried what u have suggested. But I want that data should be refreshed whenever user is changes the parameters. But its not happening.
    You need to tell it to refresh- Try Form.Subform.Requery- replace Form with the form's name and subform with the subform's name. I think that should do it. This is from memory, so it might be a little off.

    Also there is some data when I open the form for teh first time & no criteria ad been selected or entered
    I'm afraid I don't understand what you mean by this. Can you explain a little more?
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  11. #11
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    357
    Location
    When the subform is loaded along with the form at that time all the textboxes from where the parameters is blank. Then the subform must be blank.

    But for some reason its showing the data for the parameters previously entered, now this is completely strange.

    Sudhir

  12. #12
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    357
    Location
    Now its working fine & I used the Form.Subform.Requery its working absolutely fine.

    Thanks Randy for valuable time & guidance.




    Regards
    Sudhir

  13. #13
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    357
    Location
    I am marking this thread as sloved.

Posting Permissions

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