A2K Subform Requery

C

CJ

Hi Groupies.

In A2K3, I have the following code that works fine:

Dim stDocName As String
stDocName = "frmDriversSwampersLabourers"

Visible = False

DoCmd.SelectObject acForm, stDocName
DoCmd.Requery
DoCmd.Maximize

This code is on a command button that hides a pop up form after user input.

The problem is with the requery when I convert this code to A2K.

The parent form is frmDriversSwampersLabourers, the subform is
frmSubDriversSwampersLabourers. In A2K when I run the above code I receive
an error that says "You can't use the ApplyFilter action on this window". I
think it is because it is trying to requery the parent, not the sub.

So, I changed my code to the following:

Dim stDocName As String
stDocName = "frmDriversSwampersLabourers"

Visible = False

DoCmd.SelectObject acForm, stDocName
DoCmd.Maximize

stDocName = "frmSubDriversSwampersLabourers"
DoCmd.SelectObject acForm, stDocName
DoCmd.Requery

However, now I receive the message "The object
'frmSubDriversSwampersLabourers' isn't open."

I must have the subform requeried because the input on the pop up form
controls the sub.

Any suggestions??
Thanks
CJ
 
M

Marshall Barton

CJ said:
In A2K3, I have the following code that works fine:

Dim stDocName As String
stDocName = "frmDriversSwampersLabourers"

Visible = False

DoCmd.SelectObject acForm, stDocName
DoCmd.Requery
DoCmd.Maximize

This code is on a command button that hides a pop up form after user input.

The problem is with the requery when I convert this code to A2K.

The parent form is frmDriversSwampersLabourers, the subform is
frmSubDriversSwampersLabourers. In A2K when I run the above code I receive
an error that says "You can't use the ApplyFilter action on this window". I
think it is because it is trying to requery the parent, not the sub. [snip]
I must have the subform requeried because the input on the pop up form
controls the sub.


You should stay away from DoCmd when there is another way to
something.

In this case, you can requery the subform by using:

Forms!frmDriversSwampersLabourers.frmSubDriversSwampersLabourers.Form.Requery

No need for any of that other gobbledygook.
 
C

CJ

Alrighty then.

Thanks Marshall
Marshall Barton said:
CJ said:
In A2K3, I have the following code that works fine:

Dim stDocName As String
stDocName = "frmDriversSwampersLabourers"

Visible = False

DoCmd.SelectObject acForm, stDocName
DoCmd.Requery
DoCmd.Maximize

This code is on a command button that hides a pop up form after user
input.

The problem is with the requery when I convert this code to A2K.

The parent form is frmDriversSwampersLabourers, the subform is
frmSubDriversSwampersLabourers. In A2K when I run the above code I receive
an error that says "You can't use the ApplyFilter action on this window".
I
think it is because it is trying to requery the parent, not the sub. [snip]
I must have the subform requeried because the input on the pop up form
controls the sub.


You should stay away from DoCmd when there is another way to
something.

In this case, you can requery the subform by using:

Forms!frmDriversSwampersLabourers.frmSubDriversSwampersLabourers.Form.Requery

No need for any of that other gobbledygook.
 

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