473,657 Members | 2,515 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 2008
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
2006
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 fields F1, F5, F2 We also have a table with field names
3
18511
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 saved and an Access table is linked to the Excel worksheet. Different people collect the data in the Excel worksheet than who use the database. The fields in the table are the labels in the first row of the worksheet which is what I want. The...
3
3020
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 keep changing the field names which makes it nearly impossible to run any pre-generated queries etc. The solution really is to get someone to check the field names before importing the spreadsheet but I want to do it in code. I have written
6
1744
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 create a database in which _adding a new record automatically creates a new field in the table_ (ideally, deleting a record would also delete the field that was created when that record was added). Thus, the number of fields in the table would...
3
2462
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
9403
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
2595
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 rowsource for comboboxes with the double letters "AA" is the table I am importing into and the Row Source Type is Field List.
11
10292
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 can't figure out the coding to accomplish this. I have an Excel application that is a monster and it has become too much to maintain and test. I didn't write it but i support it. I am trying to convert this application to Access and it is not as...
4
22532
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 the table at the top of the table but the field names currently are 'field1' etc, so how do I rename the field names to the fields on the top row of the table. Cheers,
4
1604
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> <Category>MyCat</Category> </Category> </NewDataSet>
0
8413
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8740
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
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.