Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing a subform from a main form

Status
Not open for further replies.

jgarnick

Programmer
Feb 16, 2000
189
US
I have a subform placed on a main form and I get the evil #Name error for only a couple of the fields I am referencing. The other fields work. There is no circular reference, I have the syntax correct, I have triple checked the spelling and done everything else help says to do, but to no avail. One of the fields that I am referencing is a YES/NO field, the other is a text. When you open the subform alone in form or datasheet view, the fields are fine. I just can't get them to appear on my main form!!<br>
<br>
Any help would be appreciated!<br>

 
It sounds like the missing fields are not in your RecordSource for the subform.<br>
<br>
Put this piece of code in your OnOpen for the subform.<br>
<br>
Dim rst as Recordset, fld as Field<br>
Set rst = Me.RecordsetClone<br>
For Each fld in rst.Fields<br>
Debug.Print fld.Name<br>
Next<br>
<br>
After you run your form with the missing fields go into the OnOpen Event code and open the immediate window. If your field name does not show up in the above list, then you have left it out of your source somehow. This has happened to me when I have replaced my RecordSource with a vba query I built. Hope this helps.
 
Thanks for your help--the fields ARE in the recordsource of the subform--if they weren't, they wouldn't show up when I open the subform alone, correct? The recordsource is actually a query that combines two tables. But the fields are definitely in the query that is the recordsource for the subform. I'll try what you said anyways! Thanks! <p>jgarnick<br><a href=mailto:jgarnick@aol.com>jgarnick@aol.com</a><br><a href= > </a><br>
 
Yes they would show up but the #Name? means that <br>
The &quot;Control source&quot; for those fields is not part of the recordset of the form. Either you changed the &quot;Control Source&quot; or something. With the sub form open in design view Click the &quot;View&quot; Menu then click &quot;Field List&quot;. These are all of the fields connected to that sub form, compare the names to your textboxes Control Source. Also a good practice is make the &quot;Control Source&quot; and the &quot;Name&quot; of the textbox the same. <br>
Or<br>
If you are using Code Only to update the sub form. Connect thesub form to a table or query long enough to grab the field names and then un-connect it again. This will ensure they are spelled correctly. <p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top