473,508 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forms: Requery a subform from another form

I need to requery a subform from a third form and can't seem to get it to
work.

frmForm1 has frmAddress as a subform. The button cmdReviseAddress opens the
form frmUpdateAddress where all of my validation work is done and the new
record is added.

However, the new address is not being displayed in the subform.

If I use the command
Forms![frmTest]![frmAddress].Requery
it works fine.

The problem is that I want to be able to frmAddress on any form, and need to
pass the name of the main form (in this case frmForm1) as a variable.

If lsTemp = "frmForm1", the statement
Forms![lsTemp]![frmAddress].Requery (and every variation using brackets and
quotes that I can think of) fails.

Any ideas?

Thanks!
Nov 13 '05 #1
2 10867
F. Michael Miller wrote:
I need to requery a subform from a third form and can't seem to get it to
work.

frmForm1 has frmAddress as a subform. The button cmdReviseAddress opens the
form frmUpdateAddress where all of my validation work is done and the new
record is added.

However, the new address is not being displayed in the subform.

If I use the command
Forms![frmTest]![frmAddress].Requery
it works fine.

The problem is that I want to be able to frmAddress on any form, and need to
pass the name of the main form (in this case frmForm1) as a variable.

If lsTemp = "frmForm1", the statement
Forms![lsTemp]![frmAddress].Requery (and every variation using brackets and
quotes that I can think of) fails.

Any ideas?

Thanks!

Forms(lsTemp)!frmAddress.Form.Requery should work.

You could drop the following code in a Module
Public Sub FormsRequery(strForm As String, _
Optional varSubForm As Variant)

If IsMissing(varSubForm) Then
Forms(strForm).Form.Requery
Else
Forms(strForm)(varSubForm).Form.Requery
End If
End Sub

This will requery a single form or a subform if you pass both main form
and sub form names.Ex:
FormsRequery "MainFormName"
or
FormsRequery "MainFormName","SubFormName"


Nov 13 '05 #2
That works perfectly. Thanks!
"Salad" <oi*@vinegar.com> wrote in message
news:0V******************@newsread1.news.pas.earth link.net...
F. Michael Miller wrote:
I need to requery a subform from a third form and can't seem to get it to
work.

frmForm1 has frmAddress as a subform. The button cmdReviseAddress opens
the form frmUpdateAddress where all of my validation work is done and the
new record is added.

However, the new address is not being displayed in the subform.

If I use the command
Forms![frmTest]![frmAddress].Requery
it works fine.

The problem is that I want to be able to frmAddress on any form, and need
to pass the name of the main form (in this case frmForm1) as a variable.

If lsTemp = "frmForm1", the statement
Forms![lsTemp]![frmAddress].Requery (and every variation using brackets
and quotes that I can think of) fails.

Any ideas?

Thanks!

Forms(lsTemp)!frmAddress.Form.Requery should work.

You could drop the following code in a Module
Public Sub FormsRequery(strForm As String, _
Optional varSubForm As Variant)

If IsMissing(varSubForm) Then
Forms(strForm).Form.Requery
Else
Forms(strForm)(varSubForm).Form.Requery
End If
End Sub

This will requery a single form or a subform if you pass both main form
and sub form names.Ex:
FormsRequery "MainFormName"
or
FormsRequery "MainFormName","SubFormName"

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1156
by: James | last post by:
I'm pretty new to using Access and VB and have the following problem: Basically, I have a main form with a ProductID edit box and a subform which has its source object set to a query. The query...
3
12798
by: ken | last post by:
Hi, I have a main form with a text box and a filter button. I also have a subform in the main form. When I make an entry into the filter text box and click the filter button, I change the query...
1
2493
by: BartonConstruction | last post by:
Greetings all, I have a main form (frmClients) with two subforms (subVisits) (subAccount). I got the subforms to reflect what the main form is showing by linking master and child fields (I...
14
11441
by: Kurt | last post by:
I have an unbound main form with an unbound subform. frmProjects fsubProjectList Using combo boxes, the user can select several search criteria on frmProjects and then click a command button....
3
1446
by: John.Forr | last post by:
I'm creating a data-entry form for 3 tables. There is a one-to-many relationship between table1 and table2 and a 2nd one-to-many between table2 and table3. What I would like to do is have the...
2
1506
by: eighthman11 | last post by:
Hello everyone. I thought I had a perfect plan but obviously I don't. I created a continuous form which list all our company's inventory. The Continuous Form has the Inventory Number, Description...
4
13102
by: midlothian | last post by:
Hello, I have conditional formatting set up on a subform based on a calculated value in the underlying query. For instance, if Sales are >$1000, the query displays "Yes," otherwise it displays...
4
17057
by: Robert | last post by:
Hello. I have a form with 2 subforms on it, subform1 and subform2. Is there some way to requery subform2 from an after update event on one of the fields on subform1? What would the syntax of...
1
2232
by: truckfin | last post by:
Hi, i know there has been a lot of posts on refreshing/requerying comboboxes. But I cant seem to get it to do what i want. i've got a bound subform set to continuous forms on a bound form that...
0
7401
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7063
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.