Requery VBA not doing what I want...

CanadianAccessUser

Registered User.
Local time
Today, 19:14
Joined
Feb 7, 2014
Messages
114
Hi,

My code:
Code:
Private Sub cboAgent_AfterUpdate()
    Forms("NavPage").Controls("NavigationSubform").Form.Controls("frmTermAgent").Requery
    Forms("NavPage").Contkrols("NavigationSubform").Form.Controls("rptAgentsTerm").Requery
End Sub

Is supposed to take the agent from cboAgent and use it in the query criteria for a subform and subreport to show the info for the selected agent. When I choose the agent, cboAgent goes blank. I then choose the agent again and it will requery the subform and subreport properly.

Main Form: NavPage
Subform in NavigationSubform control: frmTermAgent
Subform in frmTermAgent subform control: frmTermAgentForm subform
Subreport in rptAgentsTerm control: rptAgentsTermSubreport

Is there a step I may have missed that would cause this to only work on the second attempt?
 
Try a Refresh after the Requery? Although, why it clears the ComboBox is a bit mysterious.
 
Exactly!! lol
I'll try the refresh and let you know ;)
 
I presume this is a typo?

Forms("NavPage").Contkrols
 
If I've read your post correctly then

rptAgentsTerm is a subform control in the frmTermAgent form which in turn is a sourceobject of your NavigationSubform control in your main form NavPage.

If so, what form is your cboAgent control on?

Assuming it is in your NavPage form then try this code

Code:
Private Sub cboAgent_AfterUpdate()
    me.NavigationSubform.Requery
    me.NavigationSubform.form.rptAgentsTerm.requery
End Sub

if it is elsewhere then substitute me with

Forms("NavPage")
 
The codes worked perfectly individually, but as soon as I put both actions in one code it would screw up. I ended up figuring out how to do it on one form and it works great.

Thanks for the help!
 

Users who are viewing this thread

Back
Top Bottom