Go Back   Access World Forums > Microsoft Access Discussion > Queries

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 12-06-2018, 10:43 AM   #1
sparklegrrl
Newly Registered User
 
Join Date: Jul 2003
Location: Texas
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
sparklegrrl
Send a message via ICQ to sparklegrrl Send a message via AIM to sparklegrrl Send a message via Yahoo to sparklegrrl
Requery Combo on Subform

Hi all!

I have a form with 2 combo boxes for zip codes. I have it so that when you add a new zip it updates the table and re-queries both boxes.

The problem I have is that I have a sub-form with a zip code combo box on it that also needs to be re-queried on update.

I'm having trouble finding the right code and where to put it.

Any help is greatly appreciated.

sparklegrrl is offline   Reply With Quote
Old 12-06-2018, 10:50 AM   #2
Ranman256
Newly Registered User
 
Join Date: Apr 2015
Location: KY,USA
Posts: 3,165
Thanks: 0
Thanked 692 Times in 677 Posts
Ranman256 will become famous soon enough Ranman256 will become famous soon enough
Re: Requery Combo on Subform

forms!masterform!subform!form!cboBox.requery

use the BUILDER, it will get it correct.
Ranman256 is offline   Reply With Quote
Old 12-06-2018, 11:03 AM   #3
sparklegrrl
Newly Registered User
 
Join Date: Jul 2003
Location: Texas
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
sparklegrrl
Send a message via ICQ to sparklegrrl Send a message via AIM to sparklegrrl Send a message via Yahoo to sparklegrrl
Re: Requery Combo on Subform

Quote:
Originally Posted by Ranman256 View Post
forms!masterform!subform!form!cboBox.requery

use the BUILDER, it will get it correct.
Still giving me problems...I'm about to throw this machine. LOL


sparklegrrl is offline   Reply With Quote
Old 12-06-2018, 11:04 AM   #4
sparklegrrl
Newly Registered User
 
Join Date: Jul 2003
Location: Texas
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
sparklegrrl
Send a message via ICQ to sparklegrrl Send a message via AIM to sparklegrrl Send a message via Yahoo to sparklegrrl
Re: Requery Combo on Subform

Quote:
Originally Posted by Ranman256 View Post
forms!masterform!subform!form!cboBox.requery

use the BUILDER, it will get it correct.
Here is a screen capture of the error

https://photos.app.goo.gl/FgYZsSr63CGq8u519
sparklegrrl is offline   Reply With Quote
Old 12-06-2018, 11:29 AM   #5
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 707
Thanks: 14
Thanked 162 Times in 160 Posts
MajP will become famous soon enough
Re: Requery Combo on Subform

Code:
forms!masterform!subform!form!cboBox.requery
there is a mistake there. Controls and forms are items in a collection. "Form" is a property of the subform container. Need a period.

Code:
forms!masterform!subform.form!cboBox.requery
MajP is offline   Reply With Quote
Old 12-06-2018, 11:30 AM   #6
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 707
Thanks: 14
Thanked 162 Times in 160 Posts
MajP will become famous soon enough
Re: Requery Combo on Subform

Also in the above, "subform" is the actual name of the subform control not the thing inside the control. Often the same sometimes something like child1.
MajP is offline   Reply With Quote
Old 12-06-2018, 11:33 AM   #7
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 707
Thanks: 14
Thanked 162 Times in 160 Posts
MajP will become famous soon enough
Re: Requery Combo on Subform

Also one simple trick. You can just requery every time you enter the combo. So instead of telling it to requery, just put in the combo's on enter event to requery. Depending on how much data and how often you do this, it could be an expensive choice. If this is hundreds to thousands of zips no problem 10-100s of thousands it will be slow.

MajP is offline   Reply With Quote
Old 12-06-2018, 01:37 PM   #8
sparklegrrl
Newly Registered User
 
Join Date: Jul 2003
Location: Texas
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
sparklegrrl
Send a message via ICQ to sparklegrrl Send a message via AIM to sparklegrrl Send a message via Yahoo to sparklegrrl
Re: Requery Combo on Subform

Quote:
Originally Posted by MajP View Post
Also in the above, "subform" is the actual name of the subform control not the thing inside the control. Often the same sometimes something like child1.
Subform control? You mean the combo box?

I'm actually having this issue in 2 places.

a) I need to requery/update a combo in a subform after adding data to the one on the main form (zip code) and

b) I need a cascading combo box that uses the combo box on the main form to populate the 2nd one on the subform (customer/parts)
sparklegrrl is offline   Reply With Quote
Old 12-06-2018, 01:56 PM   #9
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 707
Thanks: 14
Thanked 162 Times in 160 Posts
MajP will become famous soon enough
Re: Requery Combo on Subform

Quote:
Subform control? You mean the combo box?
No, I mean the subformControl.
Quote:
I have is that I have a sub-form with a zip code combo box on it that also needs to be re-queried on update.
We interpreted this to mean you want to requery a combobox on a subform being called from the main form after you update the rowsource on the main form.

If that is the case, then in the main form you would call it like follows

Me!NameOfSubformControl.Form!NameOfComboOnSubForm. requery

There are two different things the subform control and the thing inside the subform. Usually they have the same name by default.

For the cascade you have to requery every time. So put the code in the combobox on enter event. That is the easiest. When you go into the subform and enter the control it then requeries itself. That is easier than calling from the main. However to now reference a combobox on the main form from code in the subform you need to use Parent.
from the sub.
me.Parent.NameofControlOnMainForm
MajP is offline   Reply With Quote
Old 12-06-2018, 02:00 PM   #10
sparklegrrl
Newly Registered User
 
Join Date: Jul 2003
Location: Texas
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
sparklegrrl
Send a message via ICQ to sparklegrrl Send a message via AIM to sparklegrrl Send a message via Yahoo to sparklegrrl
Re: Requery Combo on Subform

Quote:
Originally Posted by MajP View Post
No, I mean the subformControl.


We interpreted this to mean you want to requery a combobox on a subform being called from the main form after you update the rowsource on the main form.

If that is the case, then in the main form you would call it like follows

Me!NameOfSubformControl.Form!NameOfComboOnSubForm. requery

There are two different things the subform control and the thing inside the subform. Usually they have the same name by default.

For the cascade you have to requery every time. So put the code in the combobox on enter event. That is the easiest. When you go into the subform and enter the control it then requeries itself. That is easier than calling from the main. However to now reference a combobox on the main form from code in the subform you need to use Parent.
from the sub.
me.Parent.NameofControlOnMainForm
Thank you so much! I will keep playing and see what I can do! Have a great day!
sparklegrrl is offline   Reply With Quote
Old 12-06-2018, 02:13 PM   #11
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 707
Thanks: 14
Thanked 162 Times in 160 Posts
MajP will become famous soon enough
Re: Requery Combo on Subform

If still having trouble you maybe can post a stripped down version of the db.
MajP is offline   Reply With Quote
Old 12-06-2018, 02:14 PM   #12
sparklegrrl
Newly Registered User
 
Join Date: Jul 2003
Location: Texas
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
sparklegrrl
Send a message via ICQ to sparklegrrl Send a message via AIM to sparklegrrl Send a message via Yahoo to sparklegrrl
Re: Requery Combo on Subform

Quote:
Originally Posted by MajP View Post
If still having trouble you maybe can post a stripped down version of the db.
Ok - ty! I'm going to try hard first! I learn better that way.

sparklegrrl is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box on Main form does not requery combo Box on Subform. Please Help jermaine123 Forms 3 01-13-2010 11:23 AM
Requery Combo in subform.. CEH Forms 3 12-16-2007 12:58 AM
Subform Combo Box Requery red_rhodesha Forms 8 12-29-2006 08:08 AM
SubForm Combo Box Requery madcats Forms 3 06-27-2005 10:14 AM
Requery a combo box on a subform crmarrio Forms 1 02-10-2003 08:54 AM




All times are GMT -8. The time now is 12:16 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World