Link to home
Start Free TrialLog in
Avatar of mdcadu
mdcaduFlag for United States of America

asked on

field names from RowSource SQL statement

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.
Avatar of Alan_White
Alan_White
Flag of United Kingdom of Great Britain and Northern Ireland image

Well you can get the full SQL query by referencing the rowsource property
 
eg msgbox (theFieldYouWant.rowsource)
Any help?
Avatar of mdcadu

ASKER

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.
Avatar of mdcadu

ASKER

i forgot to increase the points value, too.
ASKER CERTIFIED SOLUTION
Avatar of Alan_White
Alan_White
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mdcadu

ASKER

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!