Thought I had the solution to Lookup Box (guess I didnt)

J

jwebster1979

I have a Main form [purchase orders] and I have a subform [transaction
subform].
In my [transaction subform] I have a lookup box labled products, in my main
form [purchase orders] I have another lookup box suppliers.
My problem is I have hundreds of products and it is a pain in the butt to
figure out the one I am trying to enter in to my purchase order. I would Like
to have the products Lookup box in [transaction subform], only contain
products that are sold by the supplier I am entering in my main form
[purchase orders]. Please help and be specific I am still new at this! Thanks
Jwebster1979
 
J

John W. Vinson

I have a Main form [purchase orders] and I have a subform [transaction
subform].
In my [transaction subform] I have a lookup box labled products, in my main
form [purchase orders] I have another lookup box suppliers.
My problem is I have hundreds of products and it is a pain in the butt to
figure out the one I am trying to enter in to my purchase order. I would Like
to have the products Lookup box in [transaction subform], only contain
products that are sold by the supplier I am entering in my main form
[purchase orders]. Please help and be specific I am still new at this! Thanks
Jwebster1979

Base the combo box (the "lookup") in the Subform on a Query referencing the
supplier on the mainform:

=[Forms]![purchase orders]![supplier ID]

as a criterion on the supplier field. You'll want to Requery the combo box on
the subform in the afterupdate event of the supplier combo on the mainform:

Private Sub comboboxname_AfterUpdate()
Me![transaction subform].Form![product combo name].Requery
End Sub
 
T

Tom Wickerath

Practice first with regular forms, using one or all of these articles as a
guide:

Synchronized combo boxes

Limit content of combo/list boxes
http://www.mvps.org/access/forms/frm0028.htm

How to synchronize two combo boxes on a form in
Access 2002 or in Access 2003
http://support.microsoft.com/kb/289670

Basing one combo box on another
http://office.microsoft.com/en-us/access/HA011730581033.aspx

Since you mentioned subform, if your subform is a datasheet or continuous
form, you may have extra challenges to get your synchronized combo boxes to
work properly. Here are some references on this topic:

Synchronized combo boxes on Continuous form

Tip #16: Data in a combo box control on a continuous form/datasheet
disappears
http://www.fmsinc.com/free/newtips/access/accesstip16.asp

http://www.rogersaccesslibrary.com/download3.asp?SampleName=CascadingComboInSubform.mdb

Contributed by Sandra Daigle (3/10/2006 in microsoft.public.access):
http://groups.google.com/group/micr...frm/thread/e033253ffea2b09f/718a00e1deccf74f?

“…the problem you are seeing is due to the fact that there is really only
one combo control - it is just displayed multiple times. So whatever you have
for current rowsource will apply to all rows. This makes it difficult to use
synchronized combos on continuous forms. However, there is a fairly easy
workaround. To create the effect of a synchronized combo in a continuous form
create another textbox control, include the display column of the combo in
the Recordsource query of the form (join the foreign table and drag in the
column). Position and size the new textbox so that you can place it directly
over the combo box allowing only the down-arrow portion of the combo to show.

Create a GotFocus event for the textbox that only does a SetFocus to the
combo.

This will create the effect that you are wanting - the correct display value
will always show even though the value itself might not be fit the criteria
that is in effect based on the current record.

Here's a KB Article that explains the problem
(ACC2000:) Combo Box in Continuous Form Shows Incorrect Data
http://support.microsoft.com/kb/208866

Here's a link to my sample database that offers several different
alternatives for displaying this type of data including the technique
described above:

http://www.accessmvp.com/SDaigle/index.htm


See Access MVP Doug Steele's February, 2006 "Access Answers" column in
Pinnacle Publication's "Smart Access". You can download the column (and
sample database) for free at:
http://www.accessmvp.com/DJSteele/SmartAccess.html

His discussion of this issue begins at the bottom of page 4 of the .pdf
document.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________

jwebster1979 said:
I have a Main form [purchase orders] and I have a subform [transaction
subform].
In my [transaction subform] I have a lookup box labled products, in my main
form [purchase orders] I have another lookup box suppliers.
My problem is I have hundreds of products and it is a pain in the butt to
figure out the one I am trying to enter in to my purchase order. I would Like
to have the products Lookup box in [transaction subform], only contain
products that are sold by the supplier I am entering in my main form
[purchase orders]. Please help and be specific I am still new at this! Thanks
Jwebster1979
 
J

jwebster1979

WOW thanks for the help. No wonder I could not make it work. I will give it a
try thanks for the info!!!!

Tom Wickerath said:
Practice first with regular forms, using one or all of these articles as a
guide:

Synchronized combo boxes

Limit content of combo/list boxes
http://www.mvps.org/access/forms/frm0028.htm

How to synchronize two combo boxes on a form in
Access 2002 or in Access 2003
http://support.microsoft.com/kb/289670

Basing one combo box on another
http://office.microsoft.com/en-us/access/HA011730581033.aspx

Since you mentioned subform, if your subform is a datasheet or continuous
form, you may have extra challenges to get your synchronized combo boxes to
work properly. Here are some references on this topic:

Synchronized combo boxes on Continuous form

Tip #16: Data in a combo box control on a continuous form/datasheet
disappears
http://www.fmsinc.com/free/newtips/access/accesstip16.asp

http://www.rogersaccesslibrary.com/download3.asp?SampleName=CascadingComboInSubform.mdb

Contributed by Sandra Daigle (3/10/2006 in microsoft.public.access):
http://groups.google.com/group/micr...frm/thread/e033253ffea2b09f/718a00e1deccf74f?

“…the problem you are seeing is due to the fact that there is really only
one combo control - it is just displayed multiple times. So whatever you have
for current rowsource will apply to all rows. This makes it difficult to use
synchronized combos on continuous forms. However, there is a fairly easy
workaround. To create the effect of a synchronized combo in a continuous form
create another textbox control, include the display column of the combo in
the Recordsource query of the form (join the foreign table and drag in the
column). Position and size the new textbox so that you can place it directly
over the combo box allowing only the down-arrow portion of the combo to show.

Create a GotFocus event for the textbox that only does a SetFocus to the
combo.

This will create the effect that you are wanting - the correct display value
will always show even though the value itself might not be fit the criteria
that is in effect based on the current record.

Here's a KB Article that explains the problem
(ACC2000:) Combo Box in Continuous Form Shows Incorrect Data
http://support.microsoft.com/kb/208866

Here's a link to my sample database that offers several different
alternatives for displaying this type of data including the technique
described above:

http://www.accessmvp.com/SDaigle/index.htm


See Access MVP Doug Steele's February, 2006 "Access Answers" column in
Pinnacle Publication's "Smart Access". You can download the column (and
sample database) for free at:
http://www.accessmvp.com/DJSteele/SmartAccess.html

His discussion of this issue begins at the bottom of page 4 of the .pdf
document.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________

jwebster1979 said:
I have a Main form [purchase orders] and I have a subform [transaction
subform].
In my [transaction subform] I have a lookup box labled products, in my main
form [purchase orders] I have another lookup box suppliers.
My problem is I have hundreds of products and it is a pain in the butt to
figure out the one I am trying to enter in to my purchase order. I would Like
to have the products Lookup box in [transaction subform], only contain
products that are sold by the supplier I am entering in my main form
[purchase orders]. Please help and be specific I am still new at this! Thanks
Jwebster1979
 
J

jwebster1979

Thanks for the help!!

John W. Vinson said:
I have a Main form [purchase orders] and I have a subform [transaction
subform].
In my [transaction subform] I have a lookup box labled products, in my main
form [purchase orders] I have another lookup box suppliers.
My problem is I have hundreds of products and it is a pain in the butt to
figure out the one I am trying to enter in to my purchase order. I would Like
to have the products Lookup box in [transaction subform], only contain
products that are sold by the supplier I am entering in my main form
[purchase orders]. Please help and be specific I am still new at this! Thanks
Jwebster1979

Base the combo box (the "lookup") in the Subform on a Query referencing the
supplier on the mainform:

=[Forms]![purchase orders]![supplier ID]

as a criterion on the supplier field. You'll want to Requery the combo box on
the subform in the afterupdate event of the supplier combo on the mainform:

Private Sub comboboxname_AfterUpdate()
Me![transaction subform].Form![product combo name].Requery
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top