Reference control on subform

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Reference control on subform

Post by D Willett »

I have a main form ( as below) with 3 subforms and they are all Continuous view, I get the "Access Can't Find The Field '|' " error.
I call the code with the following:

Code: Select all

Private Function CompDTEFill()
Me!sbfTransportDriverViewAM.Form!CompDTE = DLookup("LogDateTime", "tblAudit", "AutoID=" & Nz([AutoID], 0))
Me!sbfTransportDriverViewANY.Form!CompDTE = DLookup("LogDateTime", "tblAudit", "AutoID=" & Nz([AutoID], 0))
Me!sbfTransportDriverViewPM.Form!CompDTE = DLookup("LogDateTime", "tblAudit", "AutoID=" & Nz([AutoID], 0))
End Function
Main Form name:
frmTransportDriverView
Call CompDTEFill from this form

Is my syntax correct or is it because the subforms are continuous ?
Cheers ...

Dave.

User avatar
HansV
Administrator
Posts: 78628
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Reference control on subform

Post by HansV »

One thing to look out for is that the name of a subform as a control on its main form is not necessarily the same as its name in the Navigation Pane.
The code should use the control name. You can find this by opening the main form in design view and clicking once on the subform to select it.
The Name property in the Other tab of the Property Sheet provides the control name.

Does that provide a clue?
Best wishes,
Hans

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: Reference control on subform

Post by D Willett »

Hi Hans ( keeping you busy this week :-) )

All the names are correct, clicking once shows the correct subform name and then in the Other tab the names are the same.
This applies to each form?
Cheers ...

Dave.

User avatar
HansV
Administrator
Posts: 78628
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Reference control on subform

Post by HansV »

And are you sure that the control that you want to fill is named CompDTE on each of the subforms?
Best wishes,
Hans

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: Reference control on subform

Post by D Willett »

Yes, each subform has an unbound text control called "CompDTE"
I've renamed them CompDTE1 and changed the code also to reflect that to see what happens.

Still the same ?
Cheers ...

Dave.

User avatar
HansV
Administrator
Posts: 78628
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Reference control on subform

Post by HansV »

Could you create a stripped down version of the database, zip it and attach the zip file?
Best wishes,
Hans

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: Reference control on subform

Post by D Willett »

I've taken the easy route Hans, I know the error is telling me its a referencing problem, mispelt form, subform or control but everything does seem correct.
In the query behind each subform I've added a field:

CompDTE: DLookUp("LogDateTime","tblAudit","AutoID=" & nz([AutoID],0))

This works but makes the form sluggish, it will do for now..

Thank you for your help.
Cheers ...

Dave.