How To Use Access VBA To Copy A Table With DoCmd.CopyObject

This post was actually inspired by a question I received from this site’s chatbot.

In this post you will find how you can use Access VBA and the DoCmd.CopyObject method to copy
a blank table, and append the value of a combobox to it.

The database has just one blank table “tblFacilityBlank”, that we’ll copy and paste for each facility.

Here is the picture of the form that will be used as a “work horse” (it will do all the work)

“frmMakeTable”

Basically, all you do is select a facility from the drop down box, and the selected text will get appended to the blank table.

Then a blank table will be created for the selection made.

Here is the code:


1
2
3
4
5
6
7
8
9
10
11
Private Sub btnMakeTable_Click()
    'loeblcomservices.com
   
    Dim strNewName As String
   
    'append the combo box selected value to the text
    strNewName = "Facility_" & Me.cboFacility
   
    DoCmd.CopyObject , strNewName, acTable, "tblFacilityBlank"
   
End Sub

That’s all, let me know if you have any questions.

Here is the working example:

AccessVBACopyTable.accdb

Offsite Related Information:

“Go Fund Me” Page


($5 suggested amount)

(…10% of your gift amount will go to charity)

Free! Subscribe To Our YouTube Channel!

Free MS Access VBA Programming Course

Facebooktwitterredditpinterestlinkedinmailby feather
Tags: ,