Question : VBA to name an Access Table after a Form Control

The block of code listed below just runs your basic make table query.  I would like to use VBA to name the destination table based on a value of a form control.  For instance, if ME.txtName = “Red”, I would like to name the destination table as “tblApple_Red” as opposed to just “tblApple”.  

Does anyone have any ideas on how this can be accomplished?  Thanks!

1:
2:
3:
4:
5:
6:
Private Sub MakeTables()
With DoCmd
    .RunSQL "SELECT * INTO tblApple FROM ExternalTable1"
    .RunSQL "SELECT * INTO tblBannana FROM ExternalTable2"
    .RunSQL "SELECT * INTO tblCar FROM ExternalTable3"
End With

Answer : VBA to name an Access Table after a Form Control

Better to use the first example.  Then you will have it in both running and start up states.
Random Solutions  
 
programming4us programming4us