Requery in a subform

C

Carlos

Hi, I currently have a form called "Dbs - Financials" that contains a
secondary subform called "Form_Financials". The secondary form contains a
query whose SQL is modified whenever the user changes from one record to
another in "Dbs - Financials".

The problem I have is that the SQL is effectively changed, but the query
does not reflect these changes. I have tried several versions of the
following statement:

Application.Forms("Dbs - Financials").Forms("Form_Financials").Form.Requery

but they do not work.

What I change in the SQL statement is the filter applied to the field
"Company Name", which looks like

WHERE ((([Dbs - Companies IDs].[Company Name])="GEVITY HR INC"))

for example ("GEVITY HR INC" is the name of the company).

What should I do to have the query reflect the changes in its SQL?
 
D

Danny J. Lesandrini

Your syntax confuses me a bit. Maybe because it's not the syntax I use, and
maybe becuase it's the problem. Try this ...

I'm assuming this code is on the forms, "Dbs - Financials" and that it has a
subform object that contains the form, "Form_Financials" The trick is to find
the name of the subform object / Container itself. Let's assume you rename
it to objFinancials and set it's SourceObject property to "Form_Financials".

Then this call should work ...

Me!objFinancials.Form.Requery

I've made a lot of assumptions here, but this is the syntax that works for me.
 
J

John Spencer

How are you modifying the SQL? Are you changing the source for the sub
form?



'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
C

Carlos

John:

I have a procedure within the form "Dbs - Financials" which looks like

Private Sub Form_Current()
Dim dbs As Database
Dim qry As QueryDef

Set dbs = CurrentDb
Set qry = dbs.QueryDefs(SomeQueryName)

qry.SQL = SomeSQLStatement

Set dbs = Nothing
Set qry = Nothing
End Sub

--
Carlos


John Spencer said:
How are you modifying the SQL? Are you changing the source for the sub
form?



'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

Hi, I currently have a form called "Dbs - Financials" that contains a
secondary subform called "Form_Financials". The secondary form contains a
query whose SQL is modified whenever the user changes from one record to
another in "Dbs - Financials".

The problem I have is that the SQL is effectively changed, but the query
does not reflect these changes. I have tried several versions of the
following statement:

Application.Forms("Dbs - Financials").Forms("Form_Financials").Form.Requery

but they do not work.

What I change in the SQL statement is the filter applied to the field
"Company Name", which looks like

WHERE ((([Dbs - Companies IDs].[Company Name])="GEVITY HR INC"))

for example ("GEVITY HR INC" is the name of the company).

What should I do to have the query reflect the changes in its SQL?
 
C

Carlos

Danny: Thanks a lot for your answer. The problem I had is that I inserted the
subform manually in design mode, so the subform wasn't really being created
(who knows what I did wrong). That is, it appeared on the main form, had a
name and was linked to the query, I even accessed some of its properties from
visual basic, but it didn't show up in the forms window.

I have now inserted the form using the wizard and the subform appears as a
new object in the forms window. By now I don't need to requery the subform.

--
Carlos


Danny J. Lesandrini said:
Your syntax confuses me a bit. Maybe because it's not the syntax I use, and
maybe becuase it's the problem. Try this ...

I'm assuming this code is on the forms, "Dbs - Financials" and that it has a
subform object that contains the form, "Form_Financials" The trick is to find
the name of the subform object / Container itself. Let's assume you rename
it to objFinancials and set it's SourceObject property to "Form_Financials".

Then this call should work ...

Me!objFinancials.Form.Requery

I've made a lot of assumptions here, but this is the syntax that works for me.
--
Danny J. Lesandrini
(e-mail address removed)
www.amazecreations.com


Carlos said:
Hi, I currently have a form called "Dbs - Financials" that contains a
secondary subform called "Form_Financials". The secondary form contains a
query whose SQL is modified whenever the user changes from one record to
another in "Dbs - Financials".

The problem I have is that the SQL is effectively changed, but the query
does not reflect these changes. I have tried several versions of the
following statement:

Application.Forms("Dbs - Financials").Forms("Form_Financials").Form.Requery

but they do not work.

What I change in the SQL statement is the filter applied to the field
"Company Name", which looks like

WHERE ((([Dbs - Companies IDs].[Company Name])="GEVITY HR INC"))

for example ("GEVITY HR INC" is the name of the company).

What should I do to have the query reflect the changes in its SQL?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top