Subform call

  • Thread starter Thread starter Zanstemic
  • Start date Start date
Z

Zanstemic

I'm usig the folliowing to call a field from a table that's associated with a
field in my form.

variable = cbovariable.Column(2)

It's working fine but I have a field in a subform that I would like to
reference. Any suggestions? The subform is "Events" an the field is
"EventType"

Thanks in advance
 
Zanstemic said:
I'm usig the folliowing to call a field from a table that's associated
with a
field in my form.

variable = cbovariable.Column(2)

It's working fine but I have a field in a subform that I would like to
reference. Any suggestions? The subform is "Events" an the field is
"EventType"

Thanks in advance


Something along the lines of:

YourVariable = Me!Events!EventType

In some cases you may have to be more specific:

YourVariable = Me!Events.Form!EventType

But I believe either ought to work. Note, though, that in the above,
"Events" is assumed to be the name of the subform *control* (on the main
form). The name of that control may or may not be the same as the form that
is its Source Object, depending on how you added the subform to the form.
The important point is that you must use the name of the subform control,
even if the name of the form it displays is different.
 
I appreciate the help though still having a little difficulty. When using both

YourVariable = Me!Events!EventType
In some cases you may have to be more specific:

YourVariable = Me!Events.Form!EventType

It's coming back with the error Field Events not found. I should mention the
Event Procedure is contained in the Form and not the subform. So it needs to
make the call to the subform 'Events' or to the table 'Registration'. The Me!
seems to be looking in the current form and not the subform.

Thanks again for the help
 
Zanstemic said:
I appreciate the help though still having a little difficulty. When using
both

YourVariable = Me!Events!EventType

It's coming back with the error Field Events not found. I should mention
the
Event Procedure is contained in the Form and not the subform. So it needs
to
make the call to the subform 'Events' or to the table 'Registration'. The
Me!
seems to be looking in the current form and not the subform.

Check the name of the subform control on the main form. By that, I mean the
name of the control that is displaying the Events form. I'm guessing that
it is not named "Events". As I said in my original post, you have to use
the name of the subform control, which is not necessarily the same as tha
name of the form object that it displays.
 
Yes, that fixed it. Much to my surprise the control name of the subform was
different than what I thought. By double clicking on the subform, i was able
to find the correct name.

YourVariable = Me![Subform Name]!FieldName

I added the brackets since the name had a space in it.

Thanks so much Dirk!!
 
Back
Top