How do I reference the Second Column on a Datasheet Subform?

K

Klatuu

Not really, The column is a control and will have a name.
To reference any control on a subform from code in the main form, you have
to reference the subform control name on the main form. This is not
necessarily the same name as the form being used as the subform, but if you
used the wizard, it may be. So, the syntax is

Me!MySubformControlName.Form!ControlName
 
L

L.A. Lawyer

I want to access the value of the second column on a datasheet subform when
I click on the first column.

How do I reference that value? I know (or believe) that the reference
should end with ".Column(1)", but I don't know how to reference the subform
values themselves.

Thanks.
 
K

Klatuu

Path from where?
Assuming you are referencing it from the main form, the syntax I provided is
correct.

The name of the form identified in the subform control's Source Object
property is irrelevant. You address the subform control as you would any
other control on your form. But, you also have to identify the Form property
of the control. It is a bit confusing, but the Form property points to the
form identified in the Source Object property. So if the subform control
name is CaseListSubform and your code is in the main form's code module it
would be:

Me!CaseListSubform.Form.ControlName

If it is from a different form or code module it would be:

Forms!NameOfForm!CaseListSubform.Form.ControlName.

Where ControlName is the name of the control that is the second column.
There is no column property for a form or subform. If you were wanting to
refer to it by its index, you would use Form.Controls(index) But, it would
not necessarily be 2, because every control in the form's controls collection
will be listed. That includes, lines, command buttons, labeles, etc.

I don't mean to be rude, but if it didn't work, it is because you didn't do
it correctly.
If you continue to have difficulty, please post back with the code that is
having the problem.
 
D

Dirk Goldgar

L.A. Lawyer said:
I have tried this a dozen other combinations.

I am trying to capture the value of the second column of the subform
identified as CaseListSubform, the name of the subform itself (ie, the
source object) is CaseList. I must identify THE SECOND COLUMN. What is
the
path?


I posted an answer in the other thread you start on this subject, not
realizing you had this one already going. It's not a good idea to start
multiple threads on a subject, and generally considered bad manners. You
need to give your current respondents -- and Klatuu is one of the best -- a
chance to develop an understanding of what youre trying to do and why.
 
L

L.A. Lawyer

I have tried this a dozen other combinations.

I am trying to capture the value of the second column of the subform
identified as CaseListSubform, the name of the subform itself (ie, the
source object) is CaseList. I must identify THE SECOND COLUMN. What is the
path?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top