How to set recordsource of a subform from a form

aman

Registered User.
Local time
Today, 15:56
Joined
Oct 16, 2008
Messages
1,251
Hi All

I have a form and when the values in the controls are entered a button is clicked then I want to set the recordsource of a subform but its not working.

Code:
 If Me.cboArea.Visible = False Then
trsql = "SELECT [qryQA].[FormID], [qryQA].[StandardID], [qryQA].[Score], [qryQA].[QAID], [qryQA].[StandardDoc], [qryQA].[RefID], [qryQA].[SecName] FROM [qryQA]"
Else
strsql = "SELECT [qryQA].[FormID], [qryQA].[StandardID], [qryQA].[Score], [qryQA].[QAID], [qryQA].[StandardDoc], [qryQA].[RefID], [qryQA].[SecName] FROM [qryQA] where [qryQA].[secName]='" & Me.cboArea.Column(1) & "'"
End If
[COLOR=red]Me.sfrmQAsec.RecordSource = strsql[/COLOR]

ANy help will be much appreciated.

Thanks
 
Thanks Minty, It works. But I have another questions . Please see the attachment. In this the table shows the data in Access table and then below it is the subform . It is a continuous subform and only thing I want to get rid of is the section name for each record. Here it is "T&C File" which gets displayed for each record but in actualu I want to display the header only once and the records under this header. And then next header and the records under it and so on..

How this can be done? Thanks
 

Attachments

In the sub form design delete the header and replicate it on the form header.
 
Please see the attachment. The sheet shows the data from Access table and then below it is the subform . It is a continuous subform and only thing I want to get rid of from this is the section name for each record. Here it is

1. Call Review monitoring Debreif Form
2.Framework
3.Verint Records
4.Documentation Check Framework

The section names gets displayed for each record but in actualy I want to display the header only once and then the records under this header. And then next header and the records under it and so on..

How this can be done? Thanks
 

Attachments

You can't have separate section headers in a form. You can in a report, but you can't edit data in the report...
The only other option would possibly be some very clever conditional formatting, but I can't think of how you would do that!
 
me.subformcontrolname.FORM.recordsource = etc

you should get intellisense to prove it is working.
 

Users who are viewing this thread

Back
Top Bottom