Solved

field names from RowSource SQL statement

Posted on 2009-07-08
5
416 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Database maintenance 36 108
Microsoft Access 2016 Bug? 9 46
How force required field data entry before moving on to a new record 3 29
Access query error 3 26
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

733 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