Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 04-04-2019, 09:15 AM   #1
joejs
Newly Registered User
 
Join Date: Apr 2019
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
joejs is on a distinguished road
No Requery After Second ComboBox

I am using cascading combo-boxes (I have 2 of them) and when I make a selection in the first combobox the second combobox requeries (like I want it to) but when I make a selection from the second combobox it disregards the first combobox selection and requeries the form based on only that selection.

I have the following code:

Private Sub Combo44_AfterUpdate()

Me.FilterOn = True


Me.Filter = "Book = Forms![AIM_OfferInfo]![Combo44]"

Me.Form.Requery


End Sub
************************************************** *
Private Sub Combo44_Change()

Combo46.Requery

End Sub
************************************************** *
Private Sub Combo46_AfterUpdate()

Me.FilterOn = True

Me.Filter = "YrSeason = Forms![AIM_OfferInfo]![Combo46]"

Me.Form.Requery

End Sub
************************************************** **

I also have [Forms]![AIM_OfferInfo]![Combo44] in my row source.

I need my form to filter for the YrSeason based on the Book selection. Any tips?

joejs is offline   Reply With Quote
Old 04-04-2019, 09:23 AM   #2
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,710
Thanks: 57
Thanked 1,259 Times in 1,240 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: No Requery After Second ComboBox

Hi. Welcome to the forum. It's not clear which is the first or the second combobox, but you could try changing your code to set the Filter property first before turning it on. Also, you might try resolving the form reference in the code, in case it helps. For instance:
Code:
    Me.Filter = "Book = '" & Forms![AIM_OfferInfo]![Combo44] & "'"
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 04-04-2019, 09:26 AM   #3
joejs
Newly Registered User
 
Join Date: Apr 2019
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
joejs is on a distinguished road
Re: No Requery After Second ComboBox

Combo 44 is the first combobox and Combo 46 is the second.

joejs is offline   Reply With Quote
Old 04-04-2019, 09:27 AM   #4
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,710
Thanks: 57
Thanked 1,259 Times in 1,240 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: No Requery After Second ComboBox

Quote:
Originally Posted by joejs View Post
Combo 44 is the first combobox and Combo 46 is the second.
Did you try what I suggested?
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 04-04-2019, 09:28 AM   #5
joejs
Newly Registered User
 
Join Date: Apr 2019
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
joejs is on a distinguished road
Re: No Requery After Second ComboBox

Yes. There is no error but it still does the same thing
joejs is offline   Reply With Quote
Old 04-04-2019, 09:29 AM   #6
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,710
Thanks: 57
Thanked 1,259 Times in 1,240 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: No Requery After Second ComboBox

Quote:
Originally Posted by joejs View Post
Yes. There is no error but it still does the same thing
Try adding a Debug.Print Me.Filter to see what it is being set to.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 04-04-2019, 09:33 AM   #7
joejs
Newly Registered User
 
Join Date: Apr 2019
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
joejs is on a distinguished road
Re: No Requery After Second ComboBox

It is being set to the selection in the second combobox but it is ignoring the selection in the first one

YrSeason = Forms![AIM_OfferInfo]![Combo46]

joejs is offline   Reply With Quote
Old 04-04-2019, 09:36 AM   #8
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,710
Thanks: 57
Thanked 1,259 Times in 1,240 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: No Requery After Second ComboBox

Quote:
Originally Posted by joejs View Post
It is being set to the selection in the second combobox but it is ignoring the selection in the first one

YrSeason = Forms![AIM_OfferInfo]![Combo46]
Oh, it means you'll have to combine the two. So, try it this way:
Code:
Me.Filter = "YrSeason = '" & Me.Combo46 & "' AND Book = '" & Me.Combo44 & "'"
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
joejs (04-04-2019)
Old 04-04-2019, 09:38 AM   #9
joejs
Newly Registered User
 
Join Date: Apr 2019
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
joejs is on a distinguished road
Re: No Requery After Second ComboBox

That worked! Thank you!
joejs is offline   Reply With Quote
Old 04-04-2019, 09:48 AM   #10
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,710
Thanks: 57
Thanked 1,259 Times in 1,240 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: No Requery After Second ComboBox

Quote:
Originally Posted by joejs View Post
That worked! Thank you!
You're welcome. Glad we could assist. Good luck with your project.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 04-04-2019, 09:56 AM   #11
Mark_
Longboard on the internet
 
Join Date: Sep 2017
Location: Not the middle of no where, but I can see the road to it from my house.
Posts: 2,032
Thanks: 20
Thanked 381 Times in 374 Posts
Mark_ will become famous soon enough Mark_ will become famous soon enough
Re: No Requery After Second ComboBox

Two things...
1) Combo46 as a control name makes no sense. I'd recommend giving your controls meaningful names so that you can understand clearly what you are using them for when coding.

2) You are setting the filter in combo46
Code:
Me.Filter = "YrSeason = Forms![AIM_OfferInfo]![Combo46]"
to NOT include your original filter. I am guessing that YrSeason should be a subset of Book and that more than one Book can have the same YrSeason? If so, you would want one SUB to take care of your filter that you can call from either combo. It would look something like
Code:
SUB TCO_FILTER
DIM asFilter AS STRING

asFilter = ""
IF nz(Forms![AIM_OfferInfo]![Combo44],"") <> "" THEN
   asFilter = "Book = '" & Forms![AIM_OfferInfo]![Combo44] & "'"
End IF
IF nz( Forms![AIM_OfferInfo]![Combo46],"" ) <> ""
   IF asFilter <> "" THEN asFilter = asFilter & " AND "
   asFilter = asFilter & YrSeason = "' & Forms![AIM_OfferInfo]![Combo46] & "'"
End IF

msgbox "Filter is " & asFilter  'Use to verify you are passing exactly what you want, remove after you finish debuggin.

Me.Filter = asFilter
Me.FilterOn = True
Me.Form.Requery
You would then simply call TCO_Filter for each of your combo's.

Were I you, I'd try this out to see if it will work for you. I don't have your app so I can't actually try this.

Mark_ is offline   Reply With Quote
Reply

Tags
combobox , filter , form , requery , vba

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
requery mainform unbound combobox using subform combobox value afterupdate Mikkel Forms 3 02-27-2012 07:56 AM
Requery a comboBox Trodelphin Forms 13 09-27-2011 04:08 PM
Where to requery a combobox event Johnny Forms 3 06-08-2011 05:11 PM
ComboBox Requery pgsibson Forms 3 02-23-2008 02:57 AM
Repopulating a combobox following a requery dabbler Forms 0 10-28-2004 02:50 AM




All times are GMT -8. The time now is 04:13 AM.


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 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World