[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Using "Select * INTO"  and original table field captions carryover.

Posted on 2006-03-20
6
Medium Priority
?
338 Views
Last Modified: 2010-05-18
Experts,
    Should be an easy one. When you use a "SELECT * INTO ..." statement to create a new table, why dont the original table field captions carryover to the new table (they differ from the field names due to spaces making the forms more understandable)??

Dieszel
0
Comment
Question by:DieszelDawg
  • 3
  • 2
6 Comments
 
LVL 9

Expert Comment

by:tculler
ID: 16242344
I believe that the answer lies in the fact that SQL is the standardized way of manipulating data, and while it can create a table, the commands are quite limited in standard SQL.  The caption field property is an MS Access property, not "standard."
I think the answer lies in copying and pasting the Access object, rather than moving the data via SQL.  The approach is probably to be found in a VBA reference somewhere.  I will try and find an actual code snippet for you.

HTH,

Tim
0
 
LVL 44

Accepted Solution

by:
Leigh Purvis earned 200 total points
ID: 16242470
Yeah it's pretty standard type code to loop through and set the properties you want.

For example to just view one

Debug.Print currentdb.TableDefs("TableName").Fields("FieldName").Properties("Caption")

You could set them the same way
Loop through the fields of the old table - setting the captions in the newly created one.

The only thing to be aware of is that the Caption property doesn't exist when the field has no caption - so you'll be creating the property for each field.
0
 
LVL 9

Assisted Solution

by:tculler
tculler earned 200 total points
ID: 16242487
Okay, I found something that works in VBA.  The standard approach is to use the DoCmd.CopyObject method.  The sample below copies the Employees table in Northwind, making a backup copy (in the same database) as BUEmployees.  It could also make a copy of the table in another database by specifying the other database name as the first parameter (see the help for CopyObject from any code module).
I used two procedures, one calling the other, and passing it the table name to be copied:
Public Sub CopyTable(strTableName As String)
DoCmd.CopyObject , "BU" & strTableName, acTable, strTableName

End Sub

Public Sub TEST()
Dim strTableName As String
strTableName = "Employees"
Call CopyTable(strTableName)

End Sub

HTH,

Tim
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 9

Expert Comment

by:tculler
ID: 16242500
P.S.
    The backup copy of the table which is created using the DoCmd.CopyObject method carries over ALL properties, including the caption property.

Tim
0
 

Author Comment

by:DieszelDawg
ID: 16243144
Tim and LPurvis,
    Makes sense ... I forgot ny own rule about viewing everything I do in Access as VB and SQL, not just one or the other.
0
 

Author Comment

by:DieszelDawg
ID: 16243167
Tim and LPurvis,
     Im doubling and splitting the points.... When I asked the question I should have the the WHERE claus, which looking back is why I didnt go the COPYOBJECT route.... I didnt want the whole table recreated, just certain catagories with possible appends of other catagories later. LPurvis, I'll give it a try your way... Thanks both.

Dieszel
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question