Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SubForm Combo Box Requery Problem 3

Status
Not open for further replies.

JRA

Programmer
Apr 19, 2001
106
0
0
CA
Hello,

In my form, I'm using 2 combo boxes. My first combo box the user selects a field and in the second combo box, the selection available is based on a 'requery' value from the first combo box. Everything seems to be working properly in my origional form, BUT when I set it into my subform it doesn't work at all. Does anyone know why the requery property doesn't work properly when set in a sub-form and is there a way to correct this problem?

Thanks,
James.
 
I still need help with this. Does anybody know why a combo box requery value does not work properly when set in a sub-form? Or iis there some way to correct this?
 
What is the statement you are using to requery? Your formatting is probably incorrect, it should look like this:

[Forms]![MyFormName]![MySubFormName].Form![ControlName].Requery

HTH Joe Miller
joe.miller@flotech.net
 
Thanks for your help Joe Miller,

I just tried the code you gave me from above and it didn't seen to work. I believe I am not putting it in the correct spot. I tried it in the 'Combo264_Change' event of my ControlName (Combo264). Is that correct?

Thanks,
James.
 
Try the AfterUpdate event instead, see if that makes a difference.

Joe Miller
joe.miller@flotech.net
 
Joe,

It still didn't work. I just want to make sure I'm putting it in the right place though. I have tried putting the code in both the 'AfterUpdate' and the 'Change' events of the second combo box on the subform itself. Is this correct?

James.
 
Ok, in your original post you talked about the second box being dependent on the first box. So if you change the first box, the second gets filled and the user goes straight to the subform to enter data bypassing the second box completely should they be able to enter data?

The reason I ask this is because your requery command on the first box does cause the second box to fill with the appropriate values, but Access will not fire of either the Change or AfterUpdate events of the second box because these events on fire when the User changes something, not "the program" (ie: your code).

Try moving the code I gave you to the AfterUpdate event of the first combo box first. If this doesn't work, enter the code in the OnEnter event of the subform object itself. Hopefully we got it now! :)

Joe Miller
joe.miller@flotech.net
 
OK Joe ... I'm really sorry about not making myself clear and wasting your time, but ... my two combo boxes are actually part of my subform. On my subform I have two combo boxes. In the first combo box, the user selects a company and depending on the company selected, the second combo box lists company departments. This works fine when I set it up as a regular form, but when set-up as a subform the requery does not work.

James.
 
Can you provide me with an email address so that I can forward you a db? I made a little sample db that does what we're talking about because I think something got "lost in the sauce" while we were conversing here. Maybe this will clear us up.

Joe Miller
joe.miller@flotech.net
 
Wow!! I was going nuts with trying to refresh the combo box in my subform off of the combo box in my main form!! But the code Joe gave worked, with a bit of tweaking..

In my OnClick event for my combo in the Main Form, I put:

forms![MyMainFormName]![MySubFormName]![MySubformControlName].Requery

Thanks for the proper syntax - it was exactly what I was needing!

Carie
 
This is an old query but I have exactly the same problem as James had.

I have two combo boxes on a subform. The first combo box called company and the second combo box called contact hold a one to many relationship respectively and are updateable by the user in a separate form.
On the subform I want users to select the company combo and depending on the company selected will limit the selection in the contact combo. Unfortunately I can't limit the selection for the contact combo.

I have tried using a requery on the afterupdate event in the company combo and using a stored query in the contact combo but this still does not work.

Private Sub companyCombo_AfterUpdate()
Me!contactCombo.Requery
End Sub

Forms!subFormName!companyCombo

Can anyone please help?
 
Hi Dan7!

I was having the same problem you're having also. This may need you to call the recordsource. Are you using a query to drive the second combo box? I have found that calling the recordsource prior to the requery often solves this problem.

Private Sub companyCombo_AfterUpdate()
Me.Recordsource = &quot;<query that runs the combo box>&quot;
Me.contactcombo.requery
Me.Refresh
End Sub

Hope this helps...
 
I forgot! Another trick I use is to create an unbound textbox that gets the field value at the &quot;Click&quot; of the combo box. When you build the second combo box, you have the query look at the textbox that the first combo box assigned it's value.

Private Sub cbobox1_click()
Me.txtfield = me.cbobox.column(0)
End Sub

In the query that runs cbobox2, set the value to only equal the cbobox1 return value that is in the txtfield.

May not make sense... Sorry if it doesn't...

Email me if you need more clarification:
carie@cariengon.com
 
Hello All! I'm new to this. Can anyone help me? This may be really easy for most of you.
I have a form with two combo boxes that you select the first one and the second box lets you select the second value based on the selection in the first box.
That part works. but it doesn't update if you go back and change the selection for the first box. I don't know the proper code (or i'm really close and just need some tweaking) to get it to requery on the afterupdate event. Will someone please share with me the proper code for requerying?
Thank You!
 
BIG thx joe, been fighting wih this syntax for a day now!!Trying to update a recordsource on a subform with a unbound combo on main.

This did the trick.. :)

Forms!frmserverupdate!frmServerSubform.Form.RecordSource = &quot;qryapplicationfilter&quot; ____________________________________
Stop Animal Testing
 
Hi,

I have beed reading the thread and I have exactly the same problem that JRA orginally had. I have 2 combo boxes in a subform- Category and Products. When I select the Category I would like the Products combo box to list the related products. Could someone sent me a sample database or code?

gleegeld20@msn.com


Thanks,
Gleegeld
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top