473,750 Members | 2,292 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 cmdReviseAddres s opens the
form frmUpdateAddres s 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 10898
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 cmdReviseAddres s opens the
form frmUpdateAddres s 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)!f rmAddress.Form. Requery should work.

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

If IsMissing(varSu bForm) Then
Forms(strForm). Form.Requery
Else
Forms(strForm)( varSubForm).For m.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 "MainFormNa me"
or
FormsRequery "MainFormName", "SubFormNam e"


Nov 13 '05 #2
That works perfectly. Thanks!
"Salad" <oi*@vinegar.co m> wrote in message
news:0V******** **********@news read1.news.pas. earthlink.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 cmdReviseAddres s opens
the form frmUpdateAddres s 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)!f rmAddress.Form. Requery should work.

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

If IsMissing(varSu bForm) Then
Forms(strForm). Form.Requery
Else
Forms(strForm)( varSubForm).For m.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 "MainFormNa me"
or
FormsRequery "MainFormName", "SubFormNam e"

Nov 13 '05 #3

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

Similar topics

0
1163
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 is set to return all the values in the table with the ProductID found in the edit box. This used to work fine when I had the query criteria set to: !! However, now I need to include this form as an object in another form
3
12829
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 definition of the subform and then try to requery the subform, but no matter what I do it does not requery? While my main form is open and after I clicked on filter, I can open the subform query and see that the sql changed correctly. I can open...
1
2507
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 think--newbie here). Now I need the second subform (subAccount) to update when I add a visit in the subVisits subform. I assume that the AfterUpdate would do it, but I cant figure out what the code is to update another subform would be. Not...
14
11468
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. The command button passes the criteria as a string to a query. A subform, which is based on this query, shows the results of the search.
3
1455
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 user select from a combo box on the main form a record from Table1. That would filter the subform on the main form to just the records from Table2 with the PK from Table1. I've got everything working fine up to this point, but am a bit confused on...
2
1522
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 and Quantity on Hand. The Continuous Form is based on a Query. That works great. I placed an unbound text box on the form so people could enter a number next to each inventory item that they may need for a project. You would enter all the...
4
13194
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 "No." The conditional formatting is set up to read the 'Yes' or 'No' value and color the text accordingly. I have an event in the subform that allows users to update the sales. It actually runs an update query behind the scenes. What I want to...
4
17068
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 that be? Me.Form.Subform.subform2.requery does not seem to work. Robert
1
2242
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 has a combobox that looks up values in another bound form, and in the AfterUpdate Event the following code. = .(2 OccupantWorkstyle] = .(1) I want the subform to requery the values in workstyleDefID to ensure any changes are automatically...
0
8999
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9394
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6080
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4712
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
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 we have to send another system
3
2223
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.