Requery Not Working According to Plan

C

Commish

Greetings, right now, I am trying to use a Requery to update certain
data on my "DraftTracker_H".

In the last field that I add data to, I have an Event Procedure using
AfterUpdate


Private Sub HCRLTeam_AfterUpdate()

DoCmd.Requery "frm11_DraftTracker_H"

End Sub

It's not working, I get "Runtime error '2109': There is no field named
'frm11_DraftTracker_H' in the current record.

If I want the requery to run after I finish updating a few fields in a
records, which event should I be using?
 
J

Jon Lewis

I don't think it's a problem with the event.
IIRC DoCmd.Requery expects a control name as a parameter.
Try Forms!frm11_DraftTracker_H.Requery instead.

HTH
Jon
 
C

Commish

I don't think it's a problem with the event.
IIRC DoCmd.Requery expects a control name as a parameter.
Try Forms!frm11_DraftTracker_H.Requery instead.

HTH
Jon

Jon, Thanks for your help, I used the following VB:

Private Sub Fielding_Slot_AfterUpdate()

Forms!frm11_DraftTracker_H.Requery

End Sub

And got back this error:

Run-Time-Error '2450'

Microsoft Access can't find the form 'frm11_DraftTracker_H' reffered
to in a macro expression or Visual Basic Code.

Does this need to be in a specific event? Or would I be better off if
I put this on a button?
 
J

John W. Vinson

Jon, Thanks for your help, I used the following VB:

Private Sub Fielding_Slot_AfterUpdate()

Forms!frm11_DraftTracker_H.Requery

End Sub

And got back this error:

Run-Time-Error '2450'

Microsoft Access can't find the form 'frm11_DraftTracker_H' reffered
to in a macro expression or Visual Basic Code.

Does this need to be in a specific event? Or would I be better off if
I put this on a button?

The Forms collection contains only OPEN forms. Is there a form named
frm11_DraftTracker_H currently open at the time this code executes?
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
C

Commish

J

John W. Vinson

Yes, it is open the field that I used the AfterUpdate event on is on
that form.

I'm wondering if it's an underscore vs. blank issue. Is the Name property of
the form in fact "frm11_DraftTracker_H" or is it perhaps "frm11 DraftTracker
H"? Access will sometimes replace blanks with underscores but they're not the
same.

Failing that, I'm left to speculate that you may have some VBA corruption. Has
the database been compacted? Decompiled?
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
C

Commish

I'm wondering if it's an underscore vs. blank issue. Is the Name propertyof
the form in fact "frm11_DraftTracker_H" or is it perhaps "frm11 DraftTracker
H"? Access will sometimes replace blanks with underscores but they're notthe
same.

Failing that, I'm left to speculate that you may have some VBA corruption.. Has
the database been compacted? Decompiled?
--

             John W. Vinson [MVP]
 Microsoft's replacements for these newsgroups:
 http://social.msdn.microsoft.com/Forums/en-US/accessdev/
 http://social.answers.microsoft.com/Forums/en-US/addbuz/
 and see alsohttp://www.utteraccess.com

Jon, First of all - Thanks for all your help so far.

Yes, I use underscores _ all the time.

I compacted and repaired the database a few days ago - should it be
redone? Or should I have not done that? Decompiled? I didn't even
know that option existed, so, I wouldn't have done that....
 
C

Commish

I'm wondering if it's an underscore vs. blank issue. Is the Name propertyof
the form in fact "frm11_DraftTracker_H" or is it perhaps "frm11 DraftTracker
H"? Access will sometimes replace blanks with underscores but they're notthe
same.

Failing that, I'm left to speculate that you may have some VBA corruption.. Has
the database been compacted? Decompiled?
--

             John W. Vinson [MVP]
 Microsoft's replacements for these newsgroups:
 http://social.msdn.microsoft.com/Forums/en-US/accessdev/
 http://social.answers.microsoft.com/Forums/en-US/addbuz/
 and see alsohttp://www.utteraccess.com

If the form - "frm11_DraftTracker_H" - is in a tab control on a form,
do I need to specify its location and path? That form is on a tab on
the form named "frm11_Main" - how would that be specifically addressed?
 
J

John W. Vinson

If the form - "frm11_DraftTracker_H" - is in a tab control on a form,
do I need to specify its location and path? That form is on a tab on
the form named "frm11_Main" - how would that be specifically addressed?

The tab control is irrelevant - but the fact that it is a Subform is very
relevant! A Form in a Subform control must be referenced via its mainform, and
the name of the Subform control on that mainfor (which may or may not be the
same as the name of the form contained within that subform control): try

Forms!frm11_Main!frm11_DraftTracker_H.Form.Requery

Forms refers to the Forms collection; frm11_Main to one of the forms within
that collection; frm11_DraftTracker_H to a member of that form's Controls
collection, in this case it happens to be a Subform control rather than a
textbox or combo or some other control; .Form refers to the Form property of
that Subform control, i.e. the SourceObject form loaded into the blank box of
the Subform control. That is the object which needs to be requeried.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
C

Commish

The tab control is irrelevant - but the fact that it is a Subform is very
relevant! A Form in a Subform control must be referenced via its mainform, and
the name of the Subform control on that mainfor (which may or may not be the
same as the name of the form contained within that subform control): try

Forms!frm11_Main!frm11_DraftTracker_H.Form.Requery

Forms refers to the Forms collection; frm11_Main to one of the forms within
that collection; frm11_DraftTracker_H to a member of that form's Controls
collection, in this case it happens to be a Subform control rather than a
textbox or combo or some other control; .Form refers to the Form propertyof
that Subform control, i.e. the SourceObject form loaded into the blank box of
the Subform control. That is the object which needs to be requeried.
--

             John W. Vinson [MVP]
 Microsoft's replacements for these newsgroups:
 http://social.msdn.microsoft.com/Forums/en-US/accessdev/
 http://social.answers.microsoft.com/Forums/en-US/addbuz/
 and see alsohttp://www.utteraccess.


Jon, Thanks again for the help. After copying that line into my VBA:

Private Sub Fielding_Slot_AfterUpdate()

Forms!frm11_Main!frm11_DraftTracker_H.Form.Requery

End Sub
----------------------------------------
I still get a runtime error:

Run-Time-Error '2465'

Microsoft Access can't find the field 'frm11_DraftTracker_H' refferred
to in your expression.

Thoughts?
 
J

John W. Vinson

I still get a runtime error:

Run-Time-Error '2465'

Microsoft Access can't find the field 'frm11_DraftTracker_H' refferred
to in your expression.

Thoughts?

Just that it's possible that the name of the Form within the Subform control
is 'frm11_DraftTracker_H' but the Name property *OF THE SUBFORM CONTROL* is
something else.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top