Datasheet Column reference help

Eightball3

Registered User.
Local time
Today, 15:28
Joined
Jun 30, 2010
Messages
18
This code will retrieve the column order of a specified control name:

Forms("frmMain").Controls("frmSub").Form.Controls("field_name").ColumnOrder

I would like to retrieve the control name if the column is specified. In the above example there is a main form and the subform is a datasheet.

Anyone able to help? Thanks:)
 
Enumerate via a For loop from 0 to ...controls.count - 1;

Test each control against the column order you were given.

When you find a match, the name is

Name = Forms("frmMain").Controls("frmSub").Form.Controls(index).Name

You can also do an Exit For when you find the matching number.
 
Thanks for the reply.

I'm using this to try and determine what order the columns have been set to by the user of a datasheet. Will your suggestion give me explicit name? It seems to be only giving me the name of the control that is positioned on the original saved subform?
 
You didn't make that clear earlier. Are you saying that a user can "scramble" the order of the columns somehow? Please clarify.

I suspect that if that run-time scrambling is the case, you have to look at some other property - or perhaps some other object than the named datasheet. If it hasn't been saved yet, it might HAVE no name, in which case you can't find it by naming the sheet.
 

Users who are viewing this thread

Back
Top Bottom