Refresh (Requery?) a subform from its popup

A

Aaron G

Hi all,

I have a main form with a subform. To add data to the subform you click a
command button that opens a popup for data entry. This works fine. However,
once you close the popup after entering data, the subform does not refresh.

I know there is a command for this, but I can't get any code to work. I'm
not familiar with the refresh/requery commands and I'm not even sure which
ones I should use.

Any ideas? TIA

Aaron G
Philadelphia, PA
 
O

Ofer

Open the form as dialog, that way it will pause the code until you close that
form, and the second line will refresh the subform

docmd.OpenForm "PopUpFormName",,,,,acDialog
Me.SubFormName.Requery
 
A

Aaron G

Ofer,

Thanks for your help. I get a "Method or data member not found" error
pointing to my subform name. So I changed the line to:

Me.[Main]![JournalsClientsSub].Requery

This gives me an error (upon closing the popup) "Access can't find the field
"|" referred to in your expression.

Now I'm dealing with some extra code, so I think I might have thrown a
wrench in there somewhere.

Here's the code for the command button on the subform that opens the popoup
data entry window:

Private Sub btnAddJournal_Click()
On Error GoTo Err_btnAddJournal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "JournalsClientsPopup"

stLinkCriteria = "[ForeignClientsID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me.[Main]![JournalsClientsSub].Requery

Exit_btnAddJournal_Click:
Exit Sub

Err_btnAddJournal_Click:
MsgBox Err.Description
Resume Exit_btnAddJournal_Click
End Sub

Any ideas?

Thanks again.

Aaron G
Philadelphia, PA
 
O

Ofer

Did you try this
Private Sub btnAddJournal_Click()
On Error GoTo Err_btnAddJournal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "JournalsClientsPopup"

stLinkCriteria = "[ForeignClientsID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me.JournalsClientsSub.Requery

Exit_btnAddJournal_Click:
Exit Sub

Err_btnAddJournal_Click:
MsgBox Err.Description
Resume Exit_btnAddJournal_Click
End Sub

Aaron G said:
Ofer,

Thanks for your help. I get a "Method or data member not found" error
pointing to my subform name. So I changed the line to:

Me.[Main]![JournalsClientsSub].Requery

This gives me an error (upon closing the popup) "Access can't find the field
"|" referred to in your expression.

Now I'm dealing with some extra code, so I think I might have thrown a
wrench in there somewhere.

Here's the code for the command button on the subform that opens the popoup
data entry window:

Private Sub btnAddJournal_Click()
On Error GoTo Err_btnAddJournal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "JournalsClientsPopup"

stLinkCriteria = "[ForeignClientsID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me.[Main]![JournalsClientsSub].Requery

Exit_btnAddJournal_Click:
Exit Sub

Err_btnAddJournal_Click:
MsgBox Err.Description
Resume Exit_btnAddJournal_Click
End Sub

Any ideas?

Thanks again.

Aaron G
Philadelphia, PA


Ofer said:
Open the form as dialog, that way it will pause the code until you close that
form, and the second line will refresh the subform

docmd.OpenForm "PopUpFormName",,,,,acDialog
Me.SubFormName.Requery
 
A

Aaron G

I did (and just did again to make sure). That's when I get the "Compile
Error: Method or data member not found" error. It points to the
".JorunalsClientsSub" section of the Me.JournalsClientsSub.Requery line.

Any ideas?

Aaron G
Philadelphia, PA

Ofer said:
Did you try this
Private Sub btnAddJournal_Click()
On Error GoTo Err_btnAddJournal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "JournalsClientsPopup"

stLinkCriteria = "[ForeignClientsID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me.JournalsClientsSub.Requery

Exit_btnAddJournal_Click:
Exit Sub

Err_btnAddJournal_Click:
MsgBox Err.Description
Resume Exit_btnAddJournal_Click
End Sub

Aaron G said:
Ofer,

Thanks for your help. I get a "Method or data member not found" error
pointing to my subform name. So I changed the line to:

Me.[Main]![JournalsClientsSub].Requery

This gives me an error (upon closing the popup) "Access can't find the field
"|" referred to in your expression.

Now I'm dealing with some extra code, so I think I might have thrown a
wrench in there somewhere.

Here's the code for the command button on the subform that opens the popoup
data entry window:

Private Sub btnAddJournal_Click()
On Error GoTo Err_btnAddJournal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "JournalsClientsPopup"

stLinkCriteria = "[ForeignClientsID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me.[Main]![JournalsClientsSub].Requery

Exit_btnAddJournal_Click:
Exit Sub

Err_btnAddJournal_Click:
MsgBox Err.Description
Resume Exit_btnAddJournal_Click
End Sub

Any ideas?

Thanks again.

Aaron G
Philadelphia, PA


Ofer said:
Open the form as dialog, that way it will pause the code until you close that
form, and the second line will refresh the subform

docmd.OpenForm "PopUpFormName",,,,,acDialog
Me.SubFormName.Requery


:

Hi all,

I have a main form with a subform. To add data to the subform you click a
command button that opens a popup for data entry. This works fine. However,
once you close the popup after entering data, the subform does not refresh.

I know there is a command for this, but I can't get any code to work. I'm
not familiar with the refresh/requery commands and I'm not even sure which
ones I should use.

Any ideas? TIA

Aaron G
Philadelphia, PA
 
O

Ofer

Are sure that the name of the subform, JorunalsClientsSub

Not the name of the form, that you use as a sub form.
You need the name of the sub form in the main form.

Aaron G said:
I did (and just did again to make sure). That's when I get the "Compile
Error: Method or data member not found" error. It points to the
".JorunalsClientsSub" section of the Me.JournalsClientsSub.Requery line.

Any ideas?

Aaron G
Philadelphia, PA

Ofer said:
Did you try this
Private Sub btnAddJournal_Click()
On Error GoTo Err_btnAddJournal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "JournalsClientsPopup"

stLinkCriteria = "[ForeignClientsID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me.JournalsClientsSub.Requery

Exit_btnAddJournal_Click:
Exit Sub

Err_btnAddJournal_Click:
MsgBox Err.Description
Resume Exit_btnAddJournal_Click
End Sub

Aaron G said:
Ofer,

Thanks for your help. I get a "Method or data member not found" error
pointing to my subform name. So I changed the line to:

Me.[Main]![JournalsClientsSub].Requery

This gives me an error (upon closing the popup) "Access can't find the field
"|" referred to in your expression.

Now I'm dealing with some extra code, so I think I might have thrown a
wrench in there somewhere.

Here's the code for the command button on the subform that opens the popoup
data entry window:

Private Sub btnAddJournal_Click()
On Error GoTo Err_btnAddJournal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "JournalsClientsPopup"

stLinkCriteria = "[ForeignClientsID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me.[Main]![JournalsClientsSub].Requery

Exit_btnAddJournal_Click:
Exit Sub

Err_btnAddJournal_Click:
MsgBox Err.Description
Resume Exit_btnAddJournal_Click
End Sub

Any ideas?

Thanks again.

Aaron G
Philadelphia, PA


:

Open the form as dialog, that way it will pause the code until you close that
form, and the second line will refresh the subform

docmd.OpenForm "PopUpFormName",,,,,acDialog
Me.SubFormName.Requery


:

Hi all,

I have a main form with a subform. To add data to the subform you click a
command button that opens a popup for data entry. This works fine. However,
once you close the popup after entering data, the subform does not refresh.

I know there is a command for this, but I can't get any code to work. I'm
not familiar with the refresh/requery commands and I'm not even sure which
ones I should use.

Any ideas? TIA

Aaron G
Philadelphia, PA
 
A

Aaron G

By "the name of the sub form in the main form" do you mean the name of the
child window that has the master/child link properties? I just tried that
and I get the same error.

I had originally been using the name of the form that I was using in the
subform, which was "JournalsClientsSub". If I'm right in what you're
suggesting regarding the name of the child subform window, then I should use
"JournalsSubform". That doesn't work either.

I tried it in this format:

Me.JournalsSubform.Requery

Am I missing a object name somewhere? Please verify that I'm putting in the
right middle value for that argument.

Thanks for your patience.

Aaron G
Philadelphia, PA

Ofer said:
Are sure that the name of the subform, JorunalsClientsSub

Not the name of the form, that you use as a sub form.
You need the name of the sub form in the main form.

Aaron G said:
I did (and just did again to make sure). That's when I get the "Compile
Error: Method or data member not found" error. It points to the
".JorunalsClientsSub" section of the Me.JournalsClientsSub.Requery line.

Any ideas?

Aaron G
Philadelphia, PA

Ofer said:
Did you try this
Private Sub btnAddJournal_Click()
On Error GoTo Err_btnAddJournal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "JournalsClientsPopup"

stLinkCriteria = "[ForeignClientsID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me.JournalsClientsSub.Requery

Exit_btnAddJournal_Click:
Exit Sub

Err_btnAddJournal_Click:
MsgBox Err.Description
Resume Exit_btnAddJournal_Click
End Sub

:

Ofer,

Thanks for your help. I get a "Method or data member not found" error
pointing to my subform name. So I changed the line to:

Me.[Main]![JournalsClientsSub].Requery

This gives me an error (upon closing the popup) "Access can't find the field
"|" referred to in your expression.

Now I'm dealing with some extra code, so I think I might have thrown a
wrench in there somewhere.

Here's the code for the command button on the subform that opens the popoup
data entry window:

Private Sub btnAddJournal_Click()
On Error GoTo Err_btnAddJournal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "JournalsClientsPopup"

stLinkCriteria = "[ForeignClientsID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me.[Main]![JournalsClientsSub].Requery

Exit_btnAddJournal_Click:
Exit Sub

Err_btnAddJournal_Click:
MsgBox Err.Description
Resume Exit_btnAddJournal_Click
End Sub

Any ideas?

Thanks again.

Aaron G
Philadelphia, PA


:

Open the form as dialog, that way it will pause the code until you close that
form, and the second line will refresh the subform

docmd.OpenForm "PopUpFormName",,,,,acDialog
Me.SubFormName.Requery


:

Hi all,

I have a main form with a subform. To add data to the subform you click a
command button that opens a popup for data entry. This works fine. However,
once you close the popup after entering data, the subform does not refresh.

I know there is a command for this, but I can't get any code to work. I'm
not familiar with the refresh/requery commands and I'm not even sure which
ones I should use.

Any ideas? TIA

Aaron G
Philadelphia, PA
 
G

Gina Whipp

Try: Form_NameOfSubform.Requery



Aaron G said:
By "the name of the sub form in the main form" do you mean the name of the
child window that has the master/child link properties? I just tried that
and I get the same error.

I had originally been using the name of the form that I was using in the
subform, which was "JournalsClientsSub". If I'm right in what you're
suggesting regarding the name of the child subform window, then I should
use
"JournalsSubform". That doesn't work either.

I tried it in this format:

Me.JournalsSubform.Requery

Am I missing a object name somewhere? Please verify that I'm putting in
the
right middle value for that argument.

Thanks for your patience.

Aaron G
Philadelphia, PA

Ofer said:
Are sure that the name of the subform, JorunalsClientsSub

Not the name of the form, that you use as a sub form.
You need the name of the sub form in the main form.

Aaron G said:
I did (and just did again to make sure). That's when I get the
"Compile
Error: Method or data member not found" error. It points to the
".JorunalsClientsSub" section of the Me.JournalsClientsSub.Requery
line.

Any ideas?

Aaron G
Philadelphia, PA

:

Did you try this
Private Sub btnAddJournal_Click()
On Error GoTo Err_btnAddJournal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "JournalsClientsPopup"

stLinkCriteria = "[ForeignClientsID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me.JournalsClientsSub.Requery

Exit_btnAddJournal_Click:
Exit Sub

Err_btnAddJournal_Click:
MsgBox Err.Description
Resume Exit_btnAddJournal_Click
End Sub

:

Ofer,

Thanks for your help. I get a "Method or data member not found"
error
pointing to my subform name. So I changed the line to:

Me.[Main]![JournalsClientsSub].Requery

This gives me an error (upon closing the popup) "Access can't find
the field
"|" referred to in your expression.

Now I'm dealing with some extra code, so I think I might have
thrown a
wrench in there somewhere.

Here's the code for the command button on the subform that opens
the popoup
data entry window:

Private Sub btnAddJournal_Click()
On Error GoTo Err_btnAddJournal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "JournalsClientsPopup"

stLinkCriteria = "[ForeignClientsID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me.[Main]![JournalsClientsSub].Requery

Exit_btnAddJournal_Click:
Exit Sub

Err_btnAddJournal_Click:
MsgBox Err.Description
Resume Exit_btnAddJournal_Click
End Sub

Any ideas?

Thanks again.

Aaron G
Philadelphia, PA


:

Open the form as dialog, that way it will pause the code until
you close that
form, and the second line will refresh the subform

docmd.OpenForm "PopUpFormName",,,,,acDialog
Me.SubFormName.Requery


:

Hi all,

I have a main form with a subform. To add data to the subform
you click a
command button that opens a popup for data entry. This works
fine. However,
once you close the popup after entering data, the subform does
not refresh.

I know there is a command for this, but I can't get any code to
work. I'm
not familiar with the refresh/requery commands and I'm not even
sure which
ones I should use.

Any ideas? TIA

Aaron G
Philadelphia, PA
 
A

Aaron G

That did it!

I changed the line to "Form_JournalsClientsSub.Requery" and it's working
like a charm!

Thanks both of you for all your help.

Aaron G
Philadelphia, PA

Gina Whipp said:
Try: Form_NameOfSubform.Requery



Aaron G said:
By "the name of the sub form in the main form" do you mean the name of the
child window that has the master/child link properties? I just tried that
and I get the same error.

I had originally been using the name of the form that I was using in the
subform, which was "JournalsClientsSub". If I'm right in what you're
suggesting regarding the name of the child subform window, then I should
use
"JournalsSubform". That doesn't work either.

I tried it in this format:

Me.JournalsSubform.Requery

Am I missing a object name somewhere? Please verify that I'm putting in
the
right middle value for that argument.

Thanks for your patience.

Aaron G
Philadelphia, PA

Ofer said:
Are sure that the name of the subform, JorunalsClientsSub

Not the name of the form, that you use as a sub form.
You need the name of the sub form in the main form.

:

I did (and just did again to make sure). That's when I get the
"Compile
Error: Method or data member not found" error. It points to the
".JorunalsClientsSub" section of the Me.JournalsClientsSub.Requery
line.

Any ideas?

Aaron G
Philadelphia, PA

:

Did you try this
Private Sub btnAddJournal_Click()
On Error GoTo Err_btnAddJournal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "JournalsClientsPopup"

stLinkCriteria = "[ForeignClientsID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me.JournalsClientsSub.Requery

Exit_btnAddJournal_Click:
Exit Sub

Err_btnAddJournal_Click:
MsgBox Err.Description
Resume Exit_btnAddJournal_Click
End Sub

:

Ofer,

Thanks for your help. I get a "Method or data member not found"
error
pointing to my subform name. So I changed the line to:

Me.[Main]![JournalsClientsSub].Requery

This gives me an error (upon closing the popup) "Access can't find
the field
"|" referred to in your expression.

Now I'm dealing with some extra code, so I think I might have
thrown a
wrench in there somewhere.

Here's the code for the command button on the subform that opens
the popoup
data entry window:

Private Sub btnAddJournal_Click()
On Error GoTo Err_btnAddJournal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "JournalsClientsPopup"

stLinkCriteria = "[ForeignClientsID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me.[Main]![JournalsClientsSub].Requery

Exit_btnAddJournal_Click:
Exit Sub

Err_btnAddJournal_Click:
MsgBox Err.Description
Resume Exit_btnAddJournal_Click
End Sub

Any ideas?

Thanks again.

Aaron G
Philadelphia, PA


:

Open the form as dialog, that way it will pause the code until
you close that
form, and the second line will refresh the subform

docmd.OpenForm "PopUpFormName",,,,,acDialog
Me.SubFormName.Requery


:

Hi all,

I have a main form with a subform. To add data to the subform
you click a
command button that opens a popup for data entry. This works
fine. However,
once you close the popup after entering data, the subform does
not refresh.

I know there is a command for this, but I can't get any code to
work. I'm
not familiar with the refresh/requery commands and I'm not even
sure which
ones I should use.

Any ideas? TIA

Aaron G
Philadelphia, PA
 
A

Albert D.Kallal

Gina Whipp said:
Try: Form_NameOfSubform.Requery

NO don't use that syntax...

Don't use the above format. That is referencing the base forms (class)
object. If that form is not open, then the above code will cause the form to
open, and worse all of the forms events code runs. And, even worse, is the
form is then NOT added to the forms collection. And, more worse, if you ever
have multiple copies of the form open, then the above does allow you to
reference the correct copy. And, even more interesting is that the above
syntax will not work if a form has NO CODE.

The original poser MUST get his syntax correct.

Either.

me.NameOfSubForm.Requery

or
forms!MyMainFormName!MySubForName.Requery.

or
forms("MyMainFormName)!MySubFromName.Requery

And, to be more correct, the sub-form name, and the sub-form control on the
form are NOT always the same name. So, really:

me.NameOfSubFormControl.Requery
 
G

Gina Whipp

Never knew that Albert... sorry

Albert D.Kallal said:
NO don't use that syntax...

Don't use the above format. That is referencing the base forms (class)
object. If that form is not open, then the above code will cause the form
to open, and worse all of the forms events code runs. And, even worse, is
the form is then NOT added to the forms collection. And, more worse, if
you ever have multiple copies of the form open, then the above does allow
you to reference the correct copy. And, even more interesting is that the
above syntax will not work if a form has NO CODE.

The original poser MUST get his syntax correct.

Either.

me.NameOfSubForm.Requery

or
forms!MyMainFormName!MySubForName.Requery.

or
forms("MyMainFormName)!MySubFromName.Requery

And, to be more correct, the sub-form name, and the sub-form control on
the form are NOT always the same name. So, really:

me.NameOfSubFormControl.Requery


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.members.shaw.ca/AlbertKallal
 
G

Gina Whipp

Pressed send to fast... I use it when ALL else fails but now that I have a
better understanding, I will stay away from.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top