PDA

View Full Version : Solved: Bound SubForm to a Query in Runtime



kbsudhir
07-03-2009, 07:20 AM
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

SoftwareMatt
07-03-2009, 07:23 AM
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.

kbsudhir
07-03-2009, 07:53 AM
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...???

OBP
07-04-2009, 03:21 AM
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?

kbsudhir
07-04-2009, 08:06 AM
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.

OBP
07-04-2009, 09:46 AM
Ok, then just make the query the Record Source of the Subform in Design View.
OR use a VBA SQL Filter on the Subform.

CreganTur
07-06-2009, 12:23 PM
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:
[Forms]![FormName]![ObjectName]
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:thumb

CreganTur
07-06-2009, 12:23 PM
Stupid double posts... *grumble*

kbsudhir
07-07-2009, 06:08 AM
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.

:bow: :bow: :bow: :bow: :bow: :bow:

Thanks
Sudhir

CreganTur
07-07-2009, 07:04 AM
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 :thumb


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?

kbsudhir
07-07-2009, 09:32 AM
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

kbsudhir
07-07-2009, 09:45 AM
Now its working fine & I used the Form.Subform.Requery its working absolutely fine.

Thanks Randy for valuable time & guidance.

:bow: :bow: :bow: :bow:


Regards
Sudhir

kbsudhir
07-07-2009, 09:46 AM
I am marking this thread as sloved.