combobox result to show up

setis

Registered User.
Local time
Yesterday, 22:15
Joined
Sep 30, 2017
Messages
127
I'm sorry for the newbie question here. I know this is access 1.1 but I can't figure it out.

I have a form with a combo box which its row source is a query.

I would like the result to show automatically instead of having to click on the combo and select it manually. Is it possible?
 
Do you mean you want the combo box to :
a) drop down automatically showing all possible values
b) select the result of the query automatically

Both are possible.
a) use .dropdown in code
b) save result as a variable e.g. strResult then set combobox value = strResult

Hopefully this is enough to get you started
 
Do you mean you want the combo box to :
a) drop down automatically showing all possible values
b) select the result of the query automatically

Both are possible.
a) use .dropdown in code
b) save result as a variable e.g. strResult then set combobox value = strResult

Hopefully this is enough to get you started

Thanks! I mean b).. Would you please be able to elaborate a bit more on how to save the result as a variable and set the combobox value to that one? Do you mean the "default value"? I tried to set it to the query itself (it produces just one result per form) but nothing shows up if I don't click in it.
 
add a code to your Form's Load Event, to set the value of the combo to the first item:


Private Sub Form_Load()
Me.Combo0 = Me.Combo0.ItemData(0)
End Sub
 
add a code to your Form's Load Event, to set the value of the combo to the first item:


Private Sub Form_Load()
Me.Combo0 = Me.Combo0.ItemData(0)
End Sub

Thanks! It's crazy but it isn't working and I can't find the problem. I have the same situation with another combo in the form that I have to select manually the result.

This one, when the box TotalAmountToPay is updated or changed, it should trigger the query and put it in cmbTotalAmountToPayGBP ...

Private Sub TotalAmountToPay_AfterUpdate()
Me.cmbTotalAmountToPayGBP = Me.cmbTotalAmountToPayGBP.Column(1)
End Sub
 
Try requerying the combo box
Code:
Me.Combo0.Requery

or move the code to Form_Current
 
Thanks! It's crazy but it isn't working and I can't find the problem. I have the same situation with another combo in the form that I have to select manually the result.

This one, when the box TotalAmountToPay is updated or changed, it should trigger the query and put it in cmbTotalAmountToPayGBP ...

Private Sub TotalAmountToPay_AfterUpdate()
Me.cmbTotalAmountToPayGBP = Me.cmbTotalAmountToPayGBP.Column(1)
End Sub

Be aware that any values you set for controls in VBA Code do NOT trigger events on those controls. This is by design.

The code above makes no sense. You have a value in the bound column of a combo. You are then setting it to column(1), which won't work because it's probably not a valid value for the bound column.

...Unless column(1) IS the bound column, in which case you have just set the combo to the value it was already set to...

And there is no query being triggered here, just a column lookup.
 

Users who are viewing this thread

Back
Top Bottom