Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS Access: How to Programmatically Add a Subform

Tags:

vba

ms-access

Is there a way to programmatically add a subform to a form using Access VBA? I have a temporary table that is generated dynamically when requested by the user. If possible, I would like to create a form based on the temporary table and add it as a subform to a pre-existing form.

like image 474
Adam Avatar asked Oct 14 '22 20:10

Adam


1 Answers

The best bet is to create the subform control and set the source object to either a table or a query.

Me.NameOfSubformControl.SourceObject = "Query.Query1"
Me.NameOfSubformControl.SourceObject = "Table.Temp"

It is also possible to update the sql of a saved query to reference the new temp table.

like image 98
Fionnuala Avatar answered Dec 25 '22 20:12

Fionnuala