Help inserting a table into a form using VBA

ajochung

Registered User.
Local time
Today, 12:44
Joined
Dec 11, 2013
Messages
18
I use a button to search and link to an .xlsm file, but after linking the file, I want to import the file into an existing form using VBA (instead of drag/drop into the form). Can someone please let me know the proper command to do this, i have looked everywhere online and cannot find it :banghead:
 
You don't insert data into a form, it goes into a table.
The form reads the table.
Import using:

Docmd.transferspreadsheet .....

Or use a macro for this command.
 
Hmm, just to clarify, I've used Docmd.transferspreadsheet acLink to import the file, and I don't want to insert data into a form, I want to insert the datasheet into the form
 
I don't want to insert data into a form, I want to insert the datasheet into the form
in design view of the form, drag the table onto the form
 
Yes, to further clarify, I would like to do that operation using VBA but cannot find a command to do so.
 
I don't think a table can be used directly in a form as a RecordSource without setting up the bound controls and their ControlSources so the data is displayed.

However you can put a table into a subformcontrol and display it without having to add the controls. This is what happens when you drag a table onto a form.

Design the form with a subformcontrol and save it. Remove the Master and Child LinkFields properties if the wizard adds them.

When you want to display the table, assuming the code is on the main form:
Code:
Me.subformcontrolname.SourceObject = "Table.tablename"
 
Could you please let me know the command to do this in VBA?
once you have added a subform control to your form, do as Galaxiom suggests
 

Users who are viewing this thread

Back
Top Bottom