Datasheet form selected columns

S

Shiaip

Hi,

Is it possible to get the names of fields of selected columns? Using
Form.SelLeft and Form.SelWidth I just can get the numbers of selected
columns, but how can I find out the names of controls to which those columns
are bound? Especially when user rearranged them or if there is a hidden
column.

Thanx in advance
 
A

Axel Dahmen

Try the form's Properties collection (Me.Properties) or even the form
recordset's Properties collection (Me.Recordset.Properties). There you might
find the information you need. But be aware that these Properties
collections are not easy to wade through.

HTH,
Axel Dahmen
 
T

Tomas

I tried to use form's properties SelLeft and SelWidth, but these give me
just the numbers of the selected columns. I need to know the names of these
columns fields or at least their labels.
I didn't find anything useful by examining form's recordset properties - it
doesn't deal with user selection.
And the only answer I found searching with Google was:

"I struggled with this in the Access 2.0 days. At that time there was
no way (that I could find). I don't think that has changed. You would
want to see a SelectedColumns collection or some such; it just ain't
there. Send a request to MSFT."

Is it a real lack of MsAccess?
 
D

Douglas J. Steele

I don't see it as a lack in Access.

The idea of selecting columns from the datasheet really isn't appropriate
with a database: it's something you'd do with a spreadsheet.
 
A

Axel Dahmen

Tomas, you got me wrong. Each Access database object has its own
"Properties" collection. This collections contain properties not explicitly
available.

So, what you should do is to debug into some form event and examine the
current form's properties using the Watch pane. There will be an entry
called "Properties". Expand it, look and see... - or do it manually by
entering something like:

Me.Properties(0).Name

into the Debug pane.

You will see that there are a lot more "hidden" properties to a form than
just the ones you already know.

HTH,
Axel Dahmen


------------
 
T

Tomas

That's exactly what I did

For i =0 to Form.Properties.count - 1
debug.print Form.Properties(i).Name & " " & Form.Properties(i)
Next i

For i =0 to Form.Properties.count - 1
debug.print Form.Recordset.Properties(i).Name & " " &
Form.Recordset.Properties(i)
Next i

But still did not find anything useful, except SelLeft and SelWidth. Do You
think there could be more properties I can not get with this code? Hidden
properties?
 
T

Tomas

"The idea of selecting columns from the datasheet really isn't appropriate
with a database: it's something you'd do with a spreadsheet."

??? How do You usually sort records in the datasheet - by selecting one or
more columns and then using menu command. My problem is that I want to use
my own sorting procedure. In my project is much more faster to change the
recordsource of the form with SQL Order By clause and then requery, than to
use form's OrderBy property or form's recordset's Sort property. But in
order to do this I have to know the names of the fields of user selected
columns. Access seems to be not able to give me this information. All the
examples i found searching internet was about how to get the records using
SelTop and SelHeight, not the colums using SelLeft and SelWidth. So it seems
I will have no answer to this.
 
D

Douglas J. Steele

Consider changing your interface. Give them a list of fields to select from.
 
T

Tomas

That's what I did just an hour ago. And it seems the only way.
In anyway thanks for Your thoughts.
 
Top