Assigning Field Name in continuous form from form label

  • Thread starter Thread starter Yvette T
  • Start date Start date
Y

Yvette T

I am trying to have automatically adjusting columns of reports and forms
representing times spans.

I would like for a text box to "read" a label and then show the field that
it reads.
In a table, field names represent years, so [2006], [2007], [2008], etc.

I would like for a text box to read the label "2006" and display the field
[2006].
I wrote this but it did not work:

Function LabelField(LName As String) As Field
'this is used to look at a column heading and extract the correct year for
the form/report
LabelField = LName
End Function

Please help and thank you!
 
Let me start by saying your database design is seriously flawed. I know that
because you are asking this question. You best action would be to go back
and redesign your database. There should never be any intelligence in field
names.

The only way you could make this work would be to dynamically build an SQL
string looking at the label's Caption property and adding that as a field
name to the SQL.

But, if you do, you are only digging the hole deeper.

Please understand, I am not trying to beat you up, I really am trying to
help you get on the right track so things will be easier for you.
 
Yvette,

To put Dave's comment another way, if you have field names that contain data
(2007, 2008, 2009) instead of records that contain a [SalesYear] or some
such field, what you probably have is a spreadsheet that has been converted
to a database, or worse yet, a database that has been designed as a table.

In order to get the most out of a database, you need to structure your data
in to avoid having field names that represent what should be values in a
field. If you take the time to structure your data this way, it will make
your life sooooooo.... much easier, in the long run.

Dale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top