472,811 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 software developers and data experts.

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 10771
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
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
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
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
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
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
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
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
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
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.