awestrope
awestrope

Reputation: 11

Microsoft Access Subform won't populate

I have some code to populate a single subform on a main form with a recordset. The problem is that the records are not shown on the subform. If I open the subform as a form on it's own then with almost the same code it works perfectly:

Forms!frmCorrespondanceHolidays.RecordSource = strsql ' WORKS FINE
Me.frmCorrespondanceHolidays.Form.RecordSource = strsql 'SHOWS NO RECORDS

I have tested that if I just paste the value of strSQL into a query the correct records are returned. I am beginning to think it is a bug in Access. I have tried recreating the database by creating a new one and importing all the objects. I have also compact & repaired. Not sure what else to try!

Upvotes: 1

Views: 1889

Answers (2)

awestrope
awestrope

Reputation: 11

After further investigation I have found it is related to the sql rather than the subform. If the sql includes a query that doesn't reference the parent form records are shown. If the sql includes a query that does reference the form then no record are shown. Guess I will have to work around this limitation. Thanks for the pointers.

Upvotes: 0

HelloW
HelloW

Reputation: 1617

The name of a subform is different than the Source name of the sub report. Here is where you need to look for the name to reference in VBA. You select the subform once when the Parent form is in Design view and the look at the properties.

SubForm Name for VBA

Upvotes: 2

Related Questions