Subform - Enter the value of the parameter (1 Viewer)

eugewp

New member
Local time
Today, 09:59
Joined
Dec 10, 2020
Messages
17
I have a query based form A , it filters by a parameter that it gets from a subform [F4_OCs] in the main form [F4_Inventario]. Until here everything works.

The problem is that when using the form A as a subform in other form (B), the popup appears.

The only way to open the form B is in the main form with a button, so the parameter is avaible.

This is the filter in the query

Code:
[Formularios]![F4_Inventario]![F4_OCs].[Formulario]![Id_OC]
 
Last edited:

Minty

AWF VIP
Local time
Today, 12:59
Joined
Jul 26, 2013
Messages
8,021
If the form can be opened in either stand-alone or as a subform you will have to use code to determine where to get the source data from.
You could use an open args to set the recordsource.

Pseudo code - if you pass openargs then it's opened as a form on it own, therefore use recordsource A else it's a subform use record source B?
 

eugewp

New member
Local time
Today, 09:59
Joined
Dec 10, 2020
Messages
17
If the form can be opened in either stand-alone or as a subform you will have to use code to determine where to get the source data from.
You could use an open args to set the recordsource.

Pseudo code - if you pass openargs then it's opened as a form on it own, therefore use recordsource A else it's a subform use record source B?
Thanks for your quick reply.
I don't know about open args.
But i will try to get the parameter in the form B in some hide textbox and then call it in the query.
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:59
Joined
Sep 21, 2011
Messages
7,732
The references would be different re main and subform?

I would use a TempVar and set that from any form.?
 

eugewp

New member
Local time
Today, 09:59
Joined
Dec 10, 2020
Messages
17
Thanks for your quick reply.
I don't know about open args.
But i will try to get the parameter in the form B in some hide textbox and then call it in the query.
its works but, some really strange happens. The form don't stop requerying.
 

eugewp

New member
Local time
Today, 09:59
Joined
Dec 10, 2020
Messages
17
The references would be different re main and subform?

I would use a TempVar and set that from any form.?
The parameter is an ID.
The subform (data sheet) that i get it is in the main form.
How can i pass a TempVar to a query?
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:59
Joined
Sep 21, 2011
Messages
7,732
The parameter is an ID.
The subform (data sheet) that i get it is in the main form.
How can i pass a TempVar to a query?
You refer to it in the query instead of the form control and you set it prior to calling the query.
 

eugewp

New member
Local time
Today, 09:59
Joined
Dec 10, 2020
Messages
17
OK. It finally works... I'm sure that it isn't the rigth form to do this.
How works:
- I create a public function that gets the value of the id.
- I use it for do the query
- I put a textbox in the form with the name of que parameter of the popup and put as value the function
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:59
Joined
Sep 21, 2011
Messages
7,732
If you have set the TempVar, then you can just use that on your form or wherever?
 

eugewp

New member
Local time
Today, 09:59
Joined
Dec 10, 2020
Messages
17
If you have set the TempVar, then you can just use that on your form or wherever?
I don't need the ID actually. I need to complete some data in a table, for that a use a query (which is filtered by the ID). Whith this, i was create a form.
 

Users who are viewing this thread

Top Bottom