AdrianK
05-27-2008, 03:34 AM
Hi All,
Is there a way to set the recordsource for a subform?
I have successfully used the "Forms!Form.RecordSource" successfully on normal forms, but when I am looking to set the recordsource for a subform I cannot find a control, or get this system to work.
I am using the below code:
Dim AllOpenProjects As String
' Define variable as query to be returned
AllOpenProjects = "SELECT * FROM Data WHERE ((Data.DataStatus) <> 'Completed');"
' Open form
DoCmd.OpenForm "SearchForm", acNormal, "", "", , acNormal
' Set recourdsource to the variable defined and requery
Forms!SearchSubform.RecordSource = AllOpenProjects
Forms!SearchSubform.Requery
' Close Form
DoCmd.Close acForm, "MainForm"
Where SearchForm is the form and SearchSubform is the subform it contains
However, i'm getting an error stating that the form cannot be found, however, when I open the form seperately it opens it independent of the form itself.
Is there any way to change the source of the subform itself, whilst openning it in the form?
Thanks
Is there a way to set the recordsource for a subform?
I have successfully used the "Forms!Form.RecordSource" successfully on normal forms, but when I am looking to set the recordsource for a subform I cannot find a control, or get this system to work.
I am using the below code:
Dim AllOpenProjects As String
' Define variable as query to be returned
AllOpenProjects = "SELECT * FROM Data WHERE ((Data.DataStatus) <> 'Completed');"
' Open form
DoCmd.OpenForm "SearchForm", acNormal, "", "", , acNormal
' Set recourdsource to the variable defined and requery
Forms!SearchSubform.RecordSource = AllOpenProjects
Forms!SearchSubform.Requery
' Close Form
DoCmd.Close acForm, "MainForm"
Where SearchForm is the form and SearchSubform is the subform it contains
However, i'm getting an error stating that the form cannot be found, however, when I open the form seperately it opens it independent of the form itself.
Is there any way to change the source of the subform itself, whilst openning it in the form?
Thanks