Refreshing Subform Problem

weilerdo

Registered User.
Local time
Today, 09:54
Joined
Apr 21, 2005
Messages
109
Hi All, I found a DB that RuralGuy had posted on another thread that is exactly what I was looking for. The problem that I am having is I had to add a subform that shows comments for the classes that are scheduled. It works correctly on opening the form but I can't seem to get an code to work to refresh or requery the subform when someone changes the month on the main form. I have tried Forms![frmTraining]![frmTraining_subform].Requery on the combobox [cboMonth] and the clicknext buttons but they error out every time. I have attached a copy of the DB so that you can see what I have. Thank you in advance for looking at this.
 

Attachments

Thanks Anyways Guys I figured it out I was using the wrong requery...... FYI to anyone else who gets this it should be ME.SubformName.Form.Requery
 
I had a similar problem with Sub-Forms as well. All of my forms and sub forms needed to be displayed with different background colors depending on the setting of a field in the main form. When the forms and Sub-Forms were initially loaded, they all had the appropriate colors, but when the value in the field was changed, only the display colors in the primary forms got changed. The sub forms did not because they were already loaded, and did not recognize the change. The solution for me was to refresh the data in the Sub-Form, and then "Repaint" the Sub-Form (see example below).

Note: There is also a refresh command and a requery command that you can try as well.

If Forms!fmrWorkOrders!ProgramMode = "Production" Then
Me.FormHeader.BackColor = 12632256
Me.Detail1.BackColor = 12632256
Me.FormFooter.BackColor = 12632256

[Forms]![fmrWorkOrders].[tblInvoiceDetails].Form.FormHeader.BackColor = 12632256
[Forms]![fmrWorkOrders].[tblInvoiceDetails].Form.Form_Detail.BackColor = 12632256
[Forms]![fmrWorkOrders].[tblInvoiceDetails].Form.FormFooter.BackColor = 12632256
[Forms]![fmrWorkOrders].[tblInvoiceDetails].Form.Repaint

ElseIf Forms!fmrWorkOrders!ProgramMode = "QA Testing" Then
Me.FormHeader.BackColor = 8421631
Me.Detail1.BackColor = 8421631
Me.FormFooter.BackColor = 8421631

[Forms]![fmrWorkOrders].[tblInvoiceDetails].Form.FormHeader.BackColor = 8421631
[Forms]![fmrWorkOrders].[tblInvoiceDetails].Form.Form_Detail.BackColor = 8421631
[Forms]![fmrWorkOrders].[tblInvoiceDetails].Form.FormFooter.BackColor = 8421631
[Forms]![fmrWorkOrders].[tblInvoiceDetails].Form.Repaint

ElseIf Forms!fmrWorkOrders!ProgramMode = "Development" Then
Me.FormHeader.BackColor = 10540288
Me.Detail1.BackColor = 10540288
Me.FormFooter.BackColor = 10540288

[Forms]![fmrWorkOrders].[tblInvoiceDetails].Form.FormHeader.BackColor = 10540288
[Forms]![fmrWorkOrders].[tblInvoiceDetails].Form.Form_Detail.BackColor = 10540288
[Forms]![fmrWorkOrders].[tblInvoiceDetails].Form.FormFooter.BackColor = 10540288
[Forms]![fmrWorkOrders].[tblInvoiceDetails].Form.Repaint

End If
 
Last edited:
Can I reopen this thread because, so far as I can tell, I'm doing as instructed but I'm still not getting the subform to requery, refresh, repaint or anything.

I have a search form with a combobox to select a Field, a textbox to enter a search string into and a button to click on, which fires off some code. The code puts some SQL, based on the content of the combobox and the textbox, into qrySearch using QueryDefs which is the Record Source of the subform, called subSearch

Despite using:
With Me.subSearch.Form
.Requery
.Repaint
.Refresh
.Recalc​
End With​
I still can't get the subform to show the content of the revised query. The revised query works, in all its guises, and the subform shows the correct data if you close and reopen it. It just won't dynamically re(fresh/query/calc).
 
Last edited:
Cancel this question - I solved it using the example on this page as a model.

In short, I made the subform container invisible and removed the data source of the subform. Then added, in my code above,
.RecordSource = "qrySearch"
.Visible = true​
Now it works! I was also able to remove recalc, refresh and repaint as superfluous.
 

Users who are viewing this thread

Back
Top Bottom