Requery once a combo box selected (1 Viewer)

Milad

Registered User.
Local time
Today, 00:18
Joined
Jul 8, 2013
Messages
27
I have a form which contains two sub forms. In the first subform I have 4 fields of Cut#, Size, Quantity and Style. Once the cut# is selected, a vba code runs and fill in the rest of fields.
In second sub form I have a field of Fabric# (Combo Box) which should be restricted to the “Style” value on the first sub form. I have a query which contains the Fabric# and Corresponding style and I try to write a vba code to requery once “Style value” changes. I would be thankful if someone could help me with the code.
Thanks In advance
 

billmeye

Access Aficionado
Local time
Yesterday, 23:18
Joined
Feb 20, 2010
Messages
542
In the record source for your 'Fabric#' combobox have you set a criteria to reference the control 'Style' on the other subform?
 

Milad

Registered User.
Local time
Today, 00:18
Joined
Jul 8, 2013
Messages
27
Yes, But in order to have the combo box restricted to a chosen "Style" value the code needs to requery to update the "fabric#" combo box.
 

Cronk

Registered User.
Local time
Today, 13:18
Joined
Jul 4, 2013
Messages
2,774
A requery is not necessary if you are making reference to the first subform's value in the rowsource of the combo in the second sub form.

Post the SQL for the rowsource of the combo.
 

Milad

Registered User.
Local time
Today, 00:18
Joined
Jul 8, 2013
Messages
27
Thanks for your quick response.
This is how I referenced the first subform's value.

[Forms]![MainOrderForm]![CuttingNumForm].[Form]![Style1]

Is this what you asked for?
 

Cronk

Registered User.
Local time
Today, 13:18
Joined
Jul 4, 2013
Messages
2,774
Yes, with that in the criteria of the combo in subform2.

It's air code ie check it works but it should. Did it?
 

Milad

Registered User.
Local time
Today, 00:18
Joined
Jul 8, 2013
Messages
27
This is exactly what I have in the criteria of my query. But it does not work.
 

billmeye

Access Aficionado
Local time
Yesterday, 23:18
Joined
Feb 20, 2010
Messages
542
[Forms]![MainOrderForm]![CuttingNumForm].[Form]![Style1]
Make sure [Style1] is the controls Name, not the actual Control Source.
 

Milad

Registered User.
Local time
Today, 00:18
Joined
Jul 8, 2013
Messages
27
What you sent me is exactly same as what I used but unfortunately it does not work.
I think it's because even the "style" value fill in automatically based on the "cutting#" but I am not sure.
 

billmeye

Access Aficionado
Local time
Yesterday, 23:18
Joined
Feb 20, 2010
Messages
542
Would you like to attach your DB? I could take a look and see what is the problem.
 

Milad

Registered User.
Local time
Today, 00:18
Joined
Jul 8, 2013
Messages
27
Unfortunately I can not do that. System designed in a way that only staff who are in the office are permitted to open databases not anywhere else due to data confidentiality. Even if I send it, you would not be able to open the file.
I am pretty sure I can fix it if you could let me know how to do it.
 

billmeye

Access Aficionado
Local time
Yesterday, 23:18
Joined
Feb 20, 2010
Messages
542
Your referencing something incorrectly but without seeing it's difficult to tell. It could be your naming or recordsource that is yielding your trouble.
 

CazB

Registered User.
Local time
Today, 04:18
Joined
Jul 17, 2013
Messages
309
I had a similar issue with a form I was working on... I'm working from memory here but I seem to remember I set a requery so that when the first control is updated, the second is refreshed... that worked for me?
My second field's control source was a query which referenced the first field... will look out the code if that might be useful?
 

Cronk

Registered User.
Local time
Today, 13:18
Joined
Jul 4, 2013
Messages
2,774
Milad

If your data is confidential, then delete it or replace it with dummy data.

I don't expect you will get much further help here unless we can see your design.
 

Milad

Registered User.
Local time
Today, 00:18
Joined
Jul 8, 2013
Messages
27
Sorry for late response, I just got your feedback.
I just found a solution for it. I created a combo box in a sub form to give me a list of "style" for a specific "cut#" and then I used the combo box to restrict my "Fabric#".
It is not a perfect way but it works for me fine.
I should thank you all again for your help :)
 

Users who are viewing this thread

Top Bottom