By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,877 Members | 1,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,877 IT Pros & Developers. It's quick & easy.

Table Names And Field Names

P: n/a
Hi All,

I am trying to create an Import Form to "Map Fields" for importing many
different tables into 1.

The form I created has 2 columns of comboboxes ( A - AA) thru (J - JJ).

The rowsource for comboboxes with the double letters "AA" is the table
I am importing into and the Row Source Type is Field List.

I need to :

1) Select a table to import FROM
2) Make the selected table Fieldlist available in the single letter "A"
comboboxes
3) Be able to save this "Map"

ANY help is appreciated
EiEiO

Jan 25 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Use a query to get the names of the tables instead of a value list:

SELECT name
FROM msysobjects
WHERE flags = 0 AND type = 1

To get the column names of the selected table you can use the DAO
TableDef's Fields collection. E.g.:

Dim db As DAO.Database
Dim fld As DAO.field
Dim strTable As String

Set db = CurrentDb

strTable = Me!cboTables

For Each fld In db.TableDefs(strTable).Fields
Debug.Print fld.Name
' If you want to load the field names into a combo box:
' Me!cboFields.AddItem fld.Name
Next fld

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQ9fuzIechKqOuFEgEQJyDACfRVhBEacptIx9+kxHxOnvUt NIWxgAoIb+
88I2gZS1F3TG95OL6g47pYyZ
=iGNf
-----END PGP SIGNATURE-----
EiEiO wrote:
Hi All,

I am trying to create an Import Form to "Map Fields" for importing many
different tables into 1.

The form I created has 2 columns of comboboxes ( A - AA) thru (J - JJ).

The rowsource for comboboxes with the double letters "AA" is the table
I am importing into and the Row Source Type is Field List.

I need to :

1) Select a table to import FROM
2) Make the selected table Fieldlist available in the single letter "A"
comboboxes
3) Be able to save this "Map"

ANY help is appreciated
EiEiO

Jan 25 '06 #2

P: n/a
MG,

Thank you for your reply.
At the risk of sounding like a dope, <<To get the column names of the
selected table you can use the DAO
TableDef's Fields collection. E.g.: >> where will I insert this code?
Thank you
EiEiO

Jan 25 '06 #3

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In the VBA module of the form that is holding the ComboBoxes; in the
AfterUpdate event of the tables ComboBox.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQ9f8y4echKqOuFEgEQL44wCgps7JLtpUb49GmiYsO+gs9E P4wfwAniff
as72UBlO2n8hVKt3bZEbUoob
=UNy1
-----END PGP SIGNATURE-----

EiEiO wrote:
MG,

Thank you for your reply.
At the risk of sounding like a dope, <<To get the column names of the
selected table you can use the DAO
TableDef's Fields collection. E.g.: >> where will I insert this code?
Thank you
EiEiO

Jan 25 '06 #4

P: n/a
MG,
Great... that was it thank you!
Do you have any idea why selecting different tables without closing the
form "appends" values to the "A" comboboxes and a workaround for it? In
other words, refresh the comboboxes when a different table is selected?

I really do appreciate your help!

EiEiO

Jan 26 '06 #5

P: n/a


I "think" I'm on the right track here?
But, Access complains with Run-time error '3078' ... cannot find input
table 'iTable'

iTable = the table I am importing FROM
tImportTemp = the table I am importing TO
List210 = the listbox on my form that displays the available tables
x = the combobox on my form that contains the fieldnames from List210
xx = the combobox on my form that contains the fieldnames from
tImportTemp

Dim iTable As String
Dim tImpTemp As String
Dim x As String
Dim xx As String
tImpTemp = timporttemp
iTable = Twebbanner
x = Me.a
xx = Me.aa
DoCmd.RunSQL "insert into tImportTemp.xx SELECT iTable.x FROM iTable"
EiEiO

Jan 26 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.