Solved

field names from RowSource SQL statement

Posted on 2009-07-08
5
406 Views
Last Modified: 2012-05-07
Hello.

I need to get the field names from the SQL statement which fills the Rowsource of a listbox.  I don't want to make a trip to the database to do this.   Any ideas would be appreciated.

Thanks.
0
Comment
Question by:mdcadu
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:Alan_White
ID: 24805292
Well you can get the full SQL query by referencing the rowsource property
 
eg msgbox (theFieldYouWant.rowsource)
Any help?
0
 

Author Comment

by:mdcadu
ID: 24805419
I think i need to give a little more information on what i am trying to do.  It may not be as straightforward as I originally thought.

I have a set of controls on a form that are enabled/disabled based on a parameter value when the form opens.  I fill a listbox on that form with the saved data from the controls.  The display in the listbox is built based on the enabled/disabled controls, so that only the data matching the input parameter is displayed.  So, the user sees a series of enabled controls and then sees the matching values in the listbox below.

When editing, I want to access the listbox and fill the enabled controls with the matching values from the listbox.  I have made the control names exactly the same as the field names in the table which feeds the SQL statement for the listbox Rowsource.

What I want to do is walk through the selected row in the listbox and, for each field name, get the value and put in the matching enabled control.  What i need to know is how to query the Rowsource so that the first column returns a name of "Section", the second gives me "Township", etc.

listbox.rowsource."getFieldName", os somethign similar.  the part that i don't know how to do is the "getFieldName."

Sorry for thhe poorly worded original post.  After i did more digging, it looked like this wasn't as easy as i had thought it would be.

Thanks.
0
 

Author Comment

by:mdcadu
ID: 24805432
i forgot to increase the points value, too.
0
 
LVL 10

Accepted Solution

by:
Alan_White earned 500 total points
ID: 24805536
It is not just a matter of writing a bit of code to parse the string returned from list.rowsource to identify each element?
0
 

Author Closing Comment

by:mdcadu
ID: 31601211
Doing that will give me the field names and I will know then exactly where they are positioned in the table, so I can correlate the selected row column values with the correct field name and put in the enabled controls above.  This wouldn't be so convoluted, except that the fields have the capability of changing each time the form opens, depending on the value of the input parameter.

Thanks for the help!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now