473,320 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Copy field names from one table to records in another table

I am trying to write some VB to copy the field names from one table in
a db to a field in another table in the same database i.e., so they
appear as a set of records.

Any clue how to achieve this?

Many thanks

Nov 13 '05 #1
2 2923
This is in an unbound form with a combobox (cboPickTable)
cboPickTable rowsource:
SELECT MSysObjects.Name FROM MSysObjects WHERE (((MSysObjects.Name) Not
Like "MSys*" And (MSysObjects.Name) Not Like "tblDocument*") AND
((MSysObjects.Type)=1)) ORDER BY MSysObjects.Name;

Private Function FieldList(ByVal strTable As String)
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As Field
Dim strData As String
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("tblDocumentTables", dbOpenTable)
Set tdf = db.TableDefs(Me.cboPickTable)
For Each fld In tdf.Fields
'If strData = "" Then
' strData = fld.Name
'Else
' strData = strData & vbCrLf & fld.Name
'End If
rs.AddNew
rs.Fields(0) = strTable
rs.Fields(1) = fld.Name
rs.Update

Next fld

FieldList = strData
Set tdf = Nothing
Set db = Nothing
End Function

Private Sub Command6_Click()
Me.Text4 = FieldList(Me.cboPickTable)
End Sub

Nov 13 '05 #2
Thank you.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Earl Anderson | last post by:
I have imported an Excel worksheet into A97/WinXPH which had the new employees names in one field ( in a Last Name,First Name configuration). I wanted to split that one field ( ) into two...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
1
by: Sean Howard | last post by:
Dear All, As is my want I need to do something in Access that seems simple but cannot fathom out. I have main form with two subforms, both datasheets with an almost identical table structure....
19
by: davidgordon | last post by:
Hi, I need some pointers/help on how to do the following if it possible: In my access db, I have the following: Tables: Products, Sub-Assembly, Product-Pack Table, Products
0
by: igendreau | last post by:
I have a database with a Header table. Each record in tblHeader has two One-to-Many Relationships: with tblLines and tblKeys. The HeaderID field ties tblHeader to the other two tables. The data...
39
by: windandwaves | last post by:
Hi Folk I have to store up to eight boolean bits of information about an item in my database. e.g. with restaurant drive-through facility yellow windows
2
by: Swinky | last post by:
I hope someone can help...I feel like I'm walking in the dark without a flashlight (I'm NOT a programmer but have been called to task to do some work in Access that is above my head). I have...
5
by: rdemyan via AccessMonster.com | last post by:
I have a need to add another field to all of my tables (over 150). Not data, but an actual field. Can I code this somehow. So the code presumabley would loop through all the tables, open each...
4
by: colmkav | last post by:
Hi, I need to copy a linked table but without keeping the link. ie all the data and settings accept for the link to another db. How can I do this? Colm
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.