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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referring to field in subform

Status
Not open for further replies.

LeizladNeb

Technical User
Jan 27, 2003
7
0
0
GB
I have a button in a sub form called [frmJob] which has been made from [tblJob]. The button runs the following code with the intention of finding the number of items in [tblItem] which have the same [JobNo], and also totalling their total values.

Private Sub Command28_Click()
[ItemsInJob] = DCount("[tblItem]![ItemNo]", "tblItem", "[tblItem]![JobNo]=[tblJob]![JobNo]")
[JobValue] = DSum("[TotalItemValue]", "tblItem", "[tblItem]![JobNo]=[tblJob]![JobNo]")
End Sub

An error returns on clicking the button:

'The object doesn't contain the Automation Object 'tblJob!JobNo."

The error doesn't occur and the code works fine when I open frmJob on its own, i.e. not as a subform, so im guessing its a reference thing. Any ideas?

Thanks Ben Dalziel
 
Well, I don't see where you're refering to a form anywhere, but here's how you refer to a control on a subform:

forms!NameOfMainForm!NameOfControlThatHoldsTheSubform.form!NameOfTargetControl

If you do a search on this site for "refer to a control on a subform" you'll find several nearly identical answers.

Jeremy ==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top