473,503 Members | 10,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Obtaining field names from a table

3 New Member
I need to grab field names from a table. The table is all yes/no fields with the exception of the key field. I need all the field names that have a value of "yes".
May 6 '10 #1
5 1990
Jim Doherty
897 Recognized Expert Contributor
@tamcgly33
Consider the absolute meaning of your question because in the manner presented there can be only one logical answer and it is this:- you can only have ONE field in a table that has a 'field name' value of "yes"

If you are saying that you want to loop through a table definition and list only those field names that are of the boolean datatype Yes/No then it has a completely different meaning.
May 6 '10 #2
tamcgly33
3 New Member
@Jim Doherty
Thank you for getting back to me. Let me lay out exactly what I am doing and why I need this ability.

I have a form that brings up data in three different tables. One table is not relevant in the discussion. The relationship between to the tables of interest is a one to one relationship. Upon a save record function on the form, I need to grab the selected(check box) fields and concatenate the field names on the boolean table into a single field that is hidden on the corresponding table.
May 6 '10 #3
Jim Doherty
897 Recognized Expert Contributor
@tamcgly33
You mention a form now...so I take it you are working in a form that services a table and you are wanting to loop through the controls collection of the form at the current record displayed and return a concatenated list of only those control field names where the DATA value contained in the control is 'Yes' is that it?
May 6 '10 #4
tamcgly33
3 New Member
@Jim Doherty
That is exactly correct!
May 6 '10 #5
Jim Doherty
897 Recognized Expert Contributor
@tamcgly33

if I am reading you right then do the following:

1) Place an unbound textbox on your form and name it txtValues

Paste the following code in the OnCurrent code event for the form between the Sub and End sub lines


On Error Resume Next
Expand|Select|Wrap|Line Numbers
  1. Dim ctl As Access.Control
  2. Dim myfield As String
  3. myfield = ""
  4. For Each ctl In Me.Controls
  5.     Select Case ctl.ControlType
  6.         Case acCheckBox
  7.             If (ctl.Value = True) Then
  8.                 myfield = myfield & ctl.ControlSource & ";"
  9.             'concatenate each yes value only and strip trailing semi colon
  10.             Me!txtValues = Left(myfield, Len(myfield) - 1)
  11.             End If
  12.     End Select
  13. Next ctl
3) Save and open your form you should see a concatenated string of those controlsource names for each checkbox where there exists only the datavalue "Yes"

You can of course use this concatenated string to set a Valuelist for any listbox you might want to populate but I dont know what you have there or the defined method for presentation of these return values
May 6 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
1996
by: Dirk Van de moortel | last post by:
Hi, We have a database with some tables with (what I would denote as) 'referred field names'. Like this: DataTable1 with fields F1, F2, F3 DataTable2 with fields F3, F4, F5 DataTable3 with...
3
18502
by: Tom | last post by:
Data is collected over time in an Excel worksheet with 20 columns. The Excel worksheet starts out as a copy of a template as is filled in as data is collected. Eventually the worksheet file is...
3
3017
by: Michael | last post by:
Hi everyone, I am trying to change the field names for a table that is being exported via Excel. Its a spreadsheet that our National Office sends us but even after promise after promise they...
6
1738
by: HD | last post by:
Hello. For the following, I would appreciate if anyone could tell me: if it can be done, how it might done, and/or what search terms I could use to find the solution myself. I would like to...
3
2448
by: bitoulis | last post by:
Hi, is it possible to use the records of a table as the field names of another table? If yes, how is it done? Thanks in advance Laertes
3
9371
by: Oliver Gabriel | last post by:
Hi, i want to export a table for later import, using vba. That´s my code: export: filename = "C:\HVOtabelle.txt"
5
2592
by: EiEiO | last post by:
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...
11
10273
by: Tim Hunter | last post by:
Hi I am using WinXP and Access 2003 Is it possible to store the field names of a table in an array and then loop through the array and update the table using the field names stored in the array? I...
4
22458
by: Bob | last post by:
Hi all, I've got a table that I've imported and it has junk at the top of the table, so after import I run a delete query to remove the junk lines then I'm left with the field names I want for...
4
1598
by: | last post by:
Given an XML file (dataset.writexml), here is my output (simplified for this posting): <?xml version="1.0" standalone="yes"?> <NewDataSet> <Category> <CategoryId>80</CategoryId>...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7095
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7361
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7015
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.