View Full Version : Question make one row in a combo box to show from an event.
jaeezzy 09-12-2008, 09:57 PM Hi, I was wondering how can I display a certain index in a combo box to show up after I click a button. For eg: a combo box has values 0) Water 1) Rice 3) Curry and the default value is set to "". So, when I click a button how can I make any one of three show up? Also, where can I find API documentation for Access programs coz without it, its like walking in a dark unknown field. thanks..
John Big Booty 09-12-2008, 10:06 PM In the on click event of the button put something like;
If Ingredient = "water" then
Me.Combo = 0
elseif Ingredient = "Rice" then
Me.combo = 1
elseif Ingredient = "curry" then
Me.combo = 3
else
me.combo=""
Endif
jaeezzy 10-13-2008, 11:07 PM In the on click event of the button put something like;
If Ingredient = "water" then
Me.Combo = 0
elseif Ingredient = "Rice" then
Me.combo = 1
elseif Ingredient = "curry" then
Me.combo = 3
else
me.combo=""
Endif
thanks for the reply but it couldn't help me here's how i've done:
cval=Me![combo].ListCount
if cval > 0 Then
for ctr = 0 to cval-1
if Me![combo].column(1,ctr)=Me.txtordernbr Then
..select that index where order number from txtordernbr field is present in the combo box
End If
Next
End If
thanks
neileg 10-14-2008, 02:09 AM Why do you want to set a value in a combo on a button click? It doesn't seem like a sensible thing to to, since a combo is usually used as a selection device, not a simply a display device.
jaeezzy 10-14-2008, 02:33 AM Why do you want to set a value in a combo on a button click? It doesn't seem like a sensible thing to to, since a combo is usually used as a selection device, not a simply a display device.
thanks for the reply neileg. Actually i'm trying to make a form where there is a combo box and a textfield and user can either select value from the combo box or enter something in the text box to retrieve records. when value is selected in the combo box, order number is displayed in the text box and all the records related to that order number is displayed in the subform. similarly if user choose to directly enter the order number in the text field then respected value is selected in the combo box and the records in the subform like selecting combo box..
thanks.
neileg 10-14-2008, 04:35 AM Ah! You clearly don't know that you can type into a combo box and it will 'zoom' to the value. This is standard behaviour and needs no coding.
jaeezzy 10-14-2008, 05:02 AM Ah! You clearly don't know that you can type into a combo box and it will 'zoom' to the value. This is standard behaviour and needs no coding.
ya may be but in my case combo box contains computed values of the orders in this format:
4 ordered, 2 waiting, 8 available
now when a user selects such value from the combo box corresponding order number is displayed in the text box but if a user knows the order number he can simply enter the order number in the same text box and get the corresponding details in the combo box and details in the subform. so combo box wont be used for entering order number. thanks
John Big Booty 10-14-2008, 09:10 PM So are you saying that what you want to do, is use either the combo or the text box as the search criteria, the results of which will be displayed in a sub form?
jaeezzy 10-14-2008, 10:28 PM So are you saying that what you want to do, is use either the combo or the text box as the search criteria, the results of which will be displayed in a sub form?
yes exactly.. the thing is combo box has different key to search with and textfield has different key word for example textfield will search with the order number and combo will search with details like days waiting for order to dispatch and number dispatched (this details reflect the particular order only)
thanks
John Big Booty 10-14-2008, 11:01 PM In that case why not just create a query and put
[Forms]![FRM_Name]![Combo_Name]
in the criteria, for the field, that the Combo Result is to be searched against and
[Forms]![FRM_Name]![Textbox_Name]
in the or: criteria (ie. the next criteria row down), for the field, that the Text box is to be searched against?
jaeezzy 10-15-2008, 03:54 AM In that case why not just create a query and put
[Forms]![FRM_Name]![Combo_Name]in the criteria, for the field, that the Combo Result is to be searched against and
[Forms]![FRM_Name]![Textbox_Name]in the or: criteria (ie. the next criteria row down), for the field, that the Text box is to be searched against?
ya.. but the problem is to select the particular index of combo box (combo box will already have vlaues initialised when the form first shows up which corresponds to orders in the record). So the values are already there in combo box, i just have to select index related to order number entered in the textfield. so i might do select * from records where ordernbr = [forms]![Dispatch]![txtordernbr]; but how can i make the combo box show the related index with this event from textfield. thanks
maybe some clues here?:http://www.access-programmers.co.uk/forums/showthread.php?t=131021
|