Link to home
Start Free TrialLog in
Avatar of Marilync1266
Marilync1266

asked on

Question about Combo Boxes in Microsoft Access

I have a form where the user selects a product type from a combo box and what they select is used to narrow down the selection in the opportunity combo box.  Then when they click on create a quote, the data from the opportunity combo box is appended into a table and that record is displayed on a different form.

I would like to give user another option, instead of selecting a value in the product type combo box box they can enter a key number in the opportunity ref no text field.  Once they do that, I would like the opportunity name combo box to automatically populate with that record and the value to be displayed.  

Marilyn
create-quote.jpg
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

basically, in the afterupdate event of the opp refNo textbox, iterate thru the combo box and look for the value entered in the textbox, then select when found.

better if you can upload a db, so it will be easier to discuss this.
Avatar of Marilync1266
Marilync1266

ASKER

Can I upload without the tables?  They are linked to outside databases.  

I've attached a screen prints, the 1st is where I type in a value in the Opp Ref No field and I want the value to automatically display in the opportunity combo box, without needing to select it by clicking on the arrow.

Create-Quote-with-Opp-No.jpg
create a dummy table with the same data type as the original table.

provide the following;
a. rowsource of the combo
b. bound column of the combo
c. column count

the value you typed in the textbox, in which column of the combo box you will find that value?
test this codes, change the names of the controls accordingly

private sub textbox_afterupdate()

dim j
with me.comboname
for j=0 to .listcount-1
     if .column(0,j)= me.textbox then       'assuming the bound column is 1
       .selected(j)=true
       exit for
    end if
next
end with

end sub
The rowsource of the combo is qsel_Quote_Opportunity
The bound column is # 3 - the Opportunity Ref No which is the number you can type in the text box
The column count is 10
cboOpportunity-Properties.jpg
Hi,
I'm getting an error - member not found - see attached
combo-box-error.jpg
change .selected to .value

private sub textbox_afterupdate()

dim j
with me.comboname
for j=0 to .listcount-1
     if .column(2,j)= me.textbox then       'use 2 if bound column is 3
       .value(j)=true
       exit for
    end if
next
end with

end sub
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so much it worked!!!!