By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,650 Members | 1,980 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,650 IT Pros & Developers. It's quick & easy.

Forms: Requery a subform from another form

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.