Subform Refresh

G

Guest

I've tried about a dozen things posted on this discussion group and I'm
messing something up somewhere.

Here goes:
I have a form "Audits" with 2 subforms "AuditResults subform" (yes, there
is a space in there) and "AuditScores subform".

When I am finished with my work in "AuditResults subform", I want to click a
button that does the following:
Run an append query that will post the results to the AuditScores table
Refreshes/Requeries/Repaints the "AuditScores subform" to show the results
Goes anywhere other than where it started (insert any field here).

I've tried macros, but I can't repaint the form unless it has the focus, and
of course I can't get the macro to send the focus to the subform.
I've tried code:

Private Sub Finalize_Click()
DoCmd.RunMacro "SetFinalScore"
Me.[AuditScores_subform].SetFocus
'also tried Me.AuditScores subform.SetFocus
'and tried Me.[AuditScores subform].SetFocus
Me.[AuditScores_subform].Requery
'also tried Me.AuditScores subform.Requery
'and tried Me.[AuditScores subform].Requery
End Sub

I cannot figure out what I'm doing wrong. I'd REALLY like to do this in a
Macro (company doesn't support VB) but at this point I'll take any help I can
get. Anyone have a few minutes to help me out?
 
G

Guest

I've tried about a dozen things posted on this discussion group and I'm
messing something up somewhere.

Here goes:
I have a form "Audits" with 2 subforms "AuditResults subform" (yes, there
is a space in there) and "AuditScores subform".

When I am finished with my work in "AuditResults subform", I want to click a
button that does the following:
Run an append query that will post the results to the AuditScores table
Refreshes/Requeries/Repaints the "AuditScores subform" to show the results
Goes anywhere other than where it started (insert any field here).

I've tried macros, but I can't repaint the form unless it has the focus, and
of course I can't get the macro to send the focus to the subform.
I've tried code:

Private Sub Finalize_Click()
DoCmd.RunMacro "SetFinalScore"
Me.[AuditScores_subform].SetFocus
'also tried Me.AuditScores subform.SetFocus
'and tried Me.[AuditScores subform].SetFocus
Me.[AuditScores_subform].Requery
'also tried Me.AuditScores subform.Requery
'and tried Me.[AuditScores subform].Requery
End Sub

I cannot figure out what I'm doing wrong. I'd REALLY like to do this in a
Macro (company doesn't support VB) but at this point I'll take any help I can
get. Anyone have a few minutes to help me out?

Here is the error I get:
Run-time error '2465':
Microsoft Access can't find the field '|' referred to in your expression.
 
V

Van T. Dinh

Where is the Finalize CommandButton?

If it is on the Subform "[AuditResults subform]", you cannot use "Me" in
this case since "Me" refers to the Subform and not the MainForm.
 
L

Linda Burnside

I did something similar. In this example, I used the long-hand version of
the name for the form. The subforms are on the same parent form, but I had
trouble referring to them using the Me.Parent.etc. type of name. When I
selected a new value in the drop down in my 1st subform (Combo22) I wanted
the available values in the second subform to automatically update and be
refreshed.

Dim EstValue as String

EstValue = Me.Combo22

Forms!EmailQuote![Est_Levels subform].Form!Combo33 = EstValue
Forms!EmailQuote![Est_Levels subform].Requery

Hope this helps you out.

Linda
 
G

Guest

The Finalize command button is on the subform "AuditResults subform".

Van T. Dinh said:
Where is the Finalize CommandButton?

If it is on the Subform "[AuditResults subform]", you cannot use "Me" in
this case since "Me" refers to the Subform and not the MainForm.

--
HTH
Van T. Dinh
MVP (Access)




Robert_L_Ross said:
I've tried about a dozen things posted on this discussion group and I'm
messing something up somewhere.

Here goes:
I have a form "Audits" with 2 subforms "AuditResults subform" (yes, there
is a space in there) and "AuditScores subform".

When I am finished with my work in "AuditResults subform", I want to click a
button that does the following:
Run an append query that will post the results to the AuditScores table
Refreshes/Requeries/Repaints the "AuditScores subform" to show the results
Goes anywhere other than where it started (insert any field here).

I've tried macros, but I can't repaint the form unless it has the focus, and
of course I can't get the macro to send the focus to the subform.
I've tried code:

Private Sub Finalize_Click()
DoCmd.RunMacro "SetFinalScore"
Me.[AuditScores_subform].SetFocus
'also tried Me.AuditScores subform.SetFocus
'and tried Me.[AuditScores subform].SetFocus
Me.[AuditScores_subform].Requery
'also tried Me.AuditScores subform.Requery
'and tried Me.[AuditScores subform].Requery
End Sub

I cannot figure out what I'm doing wrong. I'd REALLY like to do this in a
Macro (company doesn't support VB) but at this point I'll take any help I can
get. Anyone have a few minutes to help me out?
 
G

Guest

So I'm guessing my version of your code would look like this?
Private Sub Finalize_Click()
DoCmd.RunMacro "SetFinalScore"
Forms!Audits![AuditScores_subform].SetFocus
Forms!Audits![AuditScores_subform].Requery
End Sub

Do I need to actually set the focus on a field in the subform, or can I just
set the subform as the focus? (Or do I need to set the focus at all - can I
just send the Requery or Repaint command without having to first move to the
subform?)

Linda Burnside said:
I did something similar. In this example, I used the long-hand version of
the name for the form. The subforms are on the same parent form, but I had
trouble referring to them using the Me.Parent.etc. type of name. When I
selected a new value in the drop down in my 1st subform (Combo22) I wanted
the available values in the second subform to automatically update and be
refreshed.

Dim EstValue as String

EstValue = Me.Combo22

Forms!EmailQuote![Est_Levels subform].Form!Combo33 = EstValue
Forms!EmailQuote![Est_Levels subform].Requery

Hope this helps you out.

Linda



Robert_L_Ross said:
I've tried about a dozen things posted on this discussion group and I'm
messing something up somewhere.

Here goes:
I have a form "Audits" with 2 subforms "AuditResults subform" (yes, there
is a space in there) and "AuditScores subform".

When I am finished with my work in "AuditResults subform", I want to click
a
button that does the following:
Run an append query that will post the results to the AuditScores table
Refreshes/Requeries/Repaints the "AuditScores subform" to show the results
Goes anywhere other than where it started (insert any field here).

I've tried macros, but I can't repaint the form unless it has the focus,
and
of course I can't get the macro to send the focus to the subform.
I've tried code:

Private Sub Finalize_Click()
DoCmd.RunMacro "SetFinalScore"
Me.[AuditScores_subform].SetFocus
'also tried Me.AuditScores subform.SetFocus
'and tried Me.[AuditScores subform].SetFocus
Me.[AuditScores_subform].Requery
'also tried Me.AuditScores subform.Requery
'and tried Me.[AuditScores subform].Requery
End Sub

I cannot figure out what I'm doing wrong. I'd REALLY like to do this in a
Macro (company doesn't support VB) but at this point I'll take any help I
can
get. Anyone have a few minutes to help me out?
 
G

Guest

Still doesn't work. When I run the code, this is the erorr I get:
"The object you referenced in the Visual Basic procedure as an OLE object
isn't an OLE object."

Here is my code now:
Private Sub Finalize_Click()
DoCmd.RunMacro "SetFinalScore"
Forms!Audits![AuditScores subform].SetFocus
Forms!Audits![AuditScores subform].Requery
End Sub

The 'DoCmd.RunMacro "SetFinalScore"' line is the one highlighted in the
debug window.

Linda Burnside said:
I did something similar. In this example, I used the long-hand version of
the name for the form. The subforms are on the same parent form, but I had
trouble referring to them using the Me.Parent.etc. type of name. When I
selected a new value in the drop down in my 1st subform (Combo22) I wanted
the available values in the second subform to automatically update and be
refreshed.

Dim EstValue as String

EstValue = Me.Combo22

Forms!EmailQuote![Est_Levels subform].Form!Combo33 = EstValue
Forms!EmailQuote![Est_Levels subform].Requery

Hope this helps you out.

Linda



Robert_L_Ross said:
I've tried about a dozen things posted on this discussion group and I'm
messing something up somewhere.

Here goes:
I have a form "Audits" with 2 subforms "AuditResults subform" (yes, there
is a space in there) and "AuditScores subform".

When I am finished with my work in "AuditResults subform", I want to click
a
button that does the following:
Run an append query that will post the results to the AuditScores table
Refreshes/Requeries/Repaints the "AuditScores subform" to show the results
Goes anywhere other than where it started (insert any field here).

I've tried macros, but I can't repaint the form unless it has the focus,
and
of course I can't get the macro to send the focus to the subform.
I've tried code:

Private Sub Finalize_Click()
DoCmd.RunMacro "SetFinalScore"
Me.[AuditScores_subform].SetFocus
'also tried Me.AuditScores subform.SetFocus
'and tried Me.[AuditScores subform].SetFocus
Me.[AuditScores_subform].Requery
'also tried Me.AuditScores subform.Requery
'and tried Me.[AuditScores subform].Requery
End Sub

I cannot figure out what I'm doing wrong. I'd REALLY like to do this in a
Macro (company doesn't support VB) but at this point I'll take any help I
can
get. Anyone have a few minutes to help me out?
 
G

Guest

FYI, it was the syntax. Everyone has been telling me to use the ! between
Forms and the name of the parent form. This is what worked:

Private Sub Finalize_Click()
DoCmd.RunMacro "SetFinalScore"
Forms.Audits.[AuditScoresSubform].Requery
End Sub

Sure would be nice if Microsoft would provide syntax for ALL commands and
references, not just the obvious ones! (...hmmm, should it be . or ! at the
end of that sentence...)

Linda Burnside said:
I did something similar. In this example, I used the long-hand version of
the name for the form. The subforms are on the same parent form, but I had
trouble referring to them using the Me.Parent.etc. type of name. When I
selected a new value in the drop down in my 1st subform (Combo22) I wanted
the available values in the second subform to automatically update and be
refreshed.

Dim EstValue as String

EstValue = Me.Combo22

Forms!EmailQuote![Est_Levels subform].Form!Combo33 = EstValue
Forms!EmailQuote![Est_Levels subform].Requery

Hope this helps you out.

Linda



Robert_L_Ross said:
I've tried about a dozen things posted on this discussion group and I'm
messing something up somewhere.

Here goes:
I have a form "Audits" with 2 subforms "AuditResults subform" (yes, there
is a space in there) and "AuditScores subform".

When I am finished with my work in "AuditResults subform", I want to click
a
button that does the following:
Run an append query that will post the results to the AuditScores table
Refreshes/Requeries/Repaints the "AuditScores subform" to show the results
Goes anywhere other than where it started (insert any field here).

I've tried macros, but I can't repaint the form unless it has the focus,
and
of course I can't get the macro to send the focus to the subform.
I've tried code:

Private Sub Finalize_Click()
DoCmd.RunMacro "SetFinalScore"
Me.[AuditScores_subform].SetFocus
'also tried Me.AuditScores subform.SetFocus
'and tried Me.[AuditScores subform].SetFocus
Me.[AuditScores_subform].Requery
'also tried Me.AuditScores subform.Requery
'and tried Me.[AuditScores subform].Requery
End Sub

I cannot figure out what I'm doing wrong. I'd REALLY like to do this in a
Macro (company doesn't support VB) but at this point I'll take any help I
can
get. Anyone have a few minutes to help me out?
 

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