467,885 Members | 1,262 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,885 developers. It's quick & easy.

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
  • viewed: 10054
Share:
2 Replies
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Kurt | last post: by
3 posts views Thread by John.Forr | last post: by
2 posts views Thread by eighthman11 | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.