Debug.Print

mlr0911

Registered User.
Local time
Today, 02:32
Joined
Oct 27, 2006
Messages
155
I have some code that tells me the table and the field names of a linked table. However, using debug.print only puts the information in my immediate window.

How can I have this go to a different table?

Here is the code:


Dim db As Database
Dim tbl As TableDef
Dim Fld As Field

Set db = CurrentDb
For Each tbl In db.TableDefs

debug.print "Table: " & tbl.name & "***"

For Each Fld In tbl.Fields

debug.print fld.name

next fld

next tbl


I have tried writing a sql that would pass the values back to a table, but that didnt' work.

Any ideas would be greatful!!


Thanks
 
Store it in a variable and use a unbound textbox to place the variable.

Edit: Missed the looping part. In that case, use a listbox and AddItem to list the fields within the table. However, this would work only for one table; if you want to list all table and its correndsponding fields, and are okay with using one long listbox, you can use conditional formatting to set the table differently from the fields' name.

But if you want to use two listbox where you can select a table and see list of fields, you probably can use a system object that gives you the list. To see those, go to your preferences (or was it option?) and turn on "View System objects". Your tables then will have several MSys.... tables. One of those lists table names and other lists fields name and how they are related. You can then use SQL to populate each listbox; look up "cascading listbox" on the forums if you need more specifics.

But if you do use MSys Objects, you MUST make sure there is no way your users can mess with those; by ensuring that the listbox are unbound, and no additions/edits/deletions are allowed in the form holding the listbox (a bit unnecessary, but better safe than sorry!). This is a surefire way to corrupt database if the data in MSys are tampered with willy-nilly.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom