Referencing Navigation Form SubForm

JamesJoey

Registered User.
Local time
Yesterday, 22:02
Joined
Dec 6, 2010
Messages
642
I'm having problems requiring an Access 2010 Navigation Form's Subform' Subform.
I run the code in the on close of an editing form called frmRemindersEdit.
frmDataSource is the name of each 'Page' of the Navigation form.

The main form names is frmHome
The Subform name is frmWeekView which has a Subform called frmDay1.
This is what I'm using on the onclose of RemindersEdit

Forms!frmHome!frmDataSource!frmDay1.Requery

I get error "2465 .....can't find the field Day1...."

Any help will be appreciated,
James
 
You are referencing the subform incorrectly. First of all, it helps to understand the difference between ! (bang) and . (dot). The ! means you are talking about a field while a . means you are talking about method or property of an object. I'm sure someone will correct me on this though. Also, when you refrence a subform as you are above, you are only referencing the subform CONTROL, not the actual subform. The subform control has a property called form that gives you access to the form that is housed in the subform control.

Code:
Forms!frmHome.frmDataSource.form!frmDay1.form.requery

edit-It seems highly unusual to have a form called day 1 by the way. I would be suspicious of your table design.

edit-Also, what is RemindersEdit?
 
I'm running the code from the On Close of frmRemindersEdit. Reminder sis the
editing form.

frmDay1 is the name of a form used in my week view. I have seven of these forms, form frmDay1 to frmDay7, all on a form I call frmWeekview.

I'm trying to do my best at replicating these week views I see in these appointment schedulers.
Although I don't require anything elaborate I simply want to display 7 columns with each column being a day from Date() to Date +6.

Oh, btw, the example you have resulted in the same error.
 
Are frmDataSource and frmDay1 the name of the forms or the form's subform control?
 
you can directly do the Requery using its form's Class Name, provided that you set Has Module property of form frmDay1 to Yes.

if you are not sure go to design view of your frmDay1 and on the property->Other->Has Module: Yes

if you have done that then:

Form_frmDay1.Requery

instead of using Forms!frmHome.frmDataSource.form!frmDay1.form.requery
 
Form_frmDay1.Requery
worked fine!

I wasn't aware of this.
Sure makes things a bit easier.
 
@arnelgp

You are again spreading a form of reference syntax to subforms that will get people into trouble unless they are fully aware of what they are doing. 99% of the readers here are not.

You do not even mention the warning that that syntax can cause closed forms and subforms to open, invisibly. And you are aware of this because I told you so in your previous post with this syntax.

So why do you do it?

Teach people rather to construct a conventional reference to items on a subform using the expression builder.

Update: I have reported my own post and hope some more moderators chime in. My report is: "Can you please read my post and that of arnelgp and offer an edict? I think arnelgp is providing tools for people to go astray, and for no good reason. "
 
Last edited:
I think the only thing that can really be done in the face of incorrect or misleading information is to describe the error, and recommend a more correct or reliable method. But the other thing is that if someone wants to build an umbrella out of pasta, or some other crazy enterprise, that is totally their business.

By way of opinion in this matter, using this code . . .
Code:
Form_Form1.Requery
. . . is not recommended, in my opinion, because it is ambiguous. Ostensibly, this code requeries the object, which is fine, but if the object is not open, this code instead opens the object, in which case a requery is not required.
So to me, this code is sloppy because the exact intent is not clear, and if this code runs under unintended circumstances it will cause unintended results.

If you want to requery a specific object, I recommend using other more precise ways to identify that object, including finding it in the Forms collection, but more commonly, passing an object reference to any routine that might need it. Similarly, if you want to open a form, I recommend using DoCmd.OpenForm, or, do some research on using "Non-Default Instances" of forms, in which case you would still be very unlikely to create instances using this declarative syntax.

Hope this help,
 
I can't use it anyhow.

It eliminated the error but it doesn't refresh (Requery) the data .
 
Hmm...if you post a stripped down version I will get it for you.
 
I suppose it should have been more like this:

Code:
Forms!Form1.[Table1 subform].Form.[Table2 Subform].Form.Requery

Here is an example. Open Form1 and Form2 and Table2. Add a new record to table2. Close the table, then click the button and the requery works.
 

Attachments

Here's the stripped down version.

It's the best I can do to re-create a week view.

I'm trying to get frmRemindersEdit On Close to requery the subform(s) on frrmHome
 

Attachments

Unrecognized database format. I'm using 2007. But I showed you how to do it in my last post. You should always develop in the 2000 format to avoid issues like this. I only upconvert to the 2003 mdb version to make the mde. I don't use accdb at all. Microsoft was stupid for not changing the extension when they released 2010.
 
i am sorry but i am not luring anybody with anything. i am just offering the OP an alternative approach. besides, there are books that says you can do it this way.
did you write to the publisher of those books or try to warn people not to patronize them? did i forget to mentions the authors are Access MVPs.

everybody here i guess is entitled for their own opinion and suggestions.

anyway so much of that if you don't want it done like that so be it.

heres, your working db sir.

Private Sub Form_Close()
' force save the record if there
' is pending update.
'
' no wonder my requery code is not
' working
If Me.Dirty Then Me.Dirty = False

If fIsLoaded("frmHome") Then

With Forms!frmHome!frmDataSource.Form
!frmDay1.Requery
!frmDay2.Requery
!frmDay3.Requery
!frmDay4.Requery
!frmDay5.Requery
!frmDay6.Requery
!frmDay1.Requery
End With
End If

'****this is for a form that i didn't include****
'If fIsLoaded("frmReminders") Then
'
' Form!frmRemninders.Requery
'
'End If
'***********************************************

If fIsLoaded("frmWeeklyAgenda") Then

Forms!frmWeeklyAgenda.Requery

End If

End Sub
 
Last edited:
I'm still getting an error:

Error 2465
MyDatbaseName can't find the field '|1' referred to in your expression.

I've pasted using my form names:
Forms!frmHome.[frmWeekView].Form.[frmDay1].Form.Requery
 
have you considered my last post (see bottom of page 1)
 
The data is getting requeried but, when I close frmRemindersEdit from frmWeeklyAgenda I get same error :
...can't find the field frmDayI

Code:
Private Sub Form_Close()
 
 If Me.Dirty Then Me.Dirty = False

 If fIsLoaded("frmHome") Then
    With Forms!frmHome!frmDataSource.Form
        !frmDay1.Requery
        !frmDay2.Requery
        !frmDay3.Requery
        !frmDay4.Requery
        !frmDay5.Requery
        !frmDay6.Requery
        !frmDay7.Requery
    End With
 End If

 If fIsLoaded("frmWeeklyAgenda") Then
     Forms!frmHome!frmDataSource.Form.frmWeeklyAgenda.Reqeury
 End If

End Sub
 
you have typo error there:

.Reqeury

should be "Requery"
 
Despite the typo, I'm still getting the same error when Weekly Agenda is the active Nav Form tab.

Works fine from frmWeekView, though.
 

Users who are viewing this thread

Back
Top Bottom