Self checking a combo box

Reshmi mohankumar

Registered User.
Local time
Today, 14:59
Joined
Dec 5, 2017
Messages
101
I need message pop up for not matching the value with combo box colomn(0) value. I used below code but not success. Please get me out from here. thank you.


Private Sub cboestdet_AfterUpdate()
Select Case cboestdet
Case Not (Me.cboestdet.Column(0))
MsgBox "Item not found", vbOKCancel
cboestdet.SetFocus
Case Else

Me.BARCODE.Value = Me.cboestdet.Column(0)
Me.Product.Value = Me.cboestdet.Column(1)
Me.Sub_product.Value = Me.cboestdet.Column(2)
Me.HSN_CODE.Value = Me.cboestdet.Column(3)
Me.Brand.Value = Me.cboestdet.Column(4)
Me.Profit_Rate.Value = Me.cboestdet.Column(5)
Me.QUANTITY.Value = Me.cboestdet.Column(6)
Me.Sales_Rate.Value = Me.cboestdet.Column(7)
Me.IS_Sold.Value = Me.cboestdet.Column(8)
Me.CGST.Value = Me.cboestdet.Column(9)
Me.SGST.Value = Me.cboestdet.Column(10)
txtProduct.SetFocus
txtSub_Product.SetFocus
txtHSN_CODE.SetFocus
txtProfit_Rate.SetFocus
txtQuantity.SetFocus
CGST.SetFocus
SGST.SetFocus
txtSales_Rate.SetFocus

End Select

End Sub
 
@Reshmi

Can you tell us in plain English what you are trying to do?
No jargon, no code --plain English.

Also, when you post code please use code tags:
-highlight the code/vba involved, then click the octothorpe/hash symbol in the message box header.
Your code will be more readable if you use some consistent indenting.


Here's a link to a free tutorial re not in list--not sure if it deals with your issue, but worth knowing about.
Good luck with your project.
 
Case Not (Me.cboestdet.Column(0))

You don't say what you're trying to match to Me.cboestdet.Column(0)!

Linq ;0)>
 
Case Not (Me.cboestdet.Column(0))

You don't say what you're trying to match to Me.cboestdet.Column(0)!

Linq ;0)>

Cboestdet is a combo box, and I am going to input value there and it has to check whether value matches in cboestdet.colomn(0) ."here combo box with multiple information I used" so I specified colomn(0)
 
If you want to limit user input to listed items, set combobox LimitToList property to yes. Then validation code is not needed.

Data validation should be done in BeforeUpdate event.

Why are you duplicating data - why are you saving same data in two tables?
 
Last edited:
Cboestdet is a combo box, and I am going to input value there and it has to check whether value matches in cboestdet.colomn(0) ."here combo box with multiple information I used" so I specified colomn(0)

Am I missing something here?
I *thought* the value in the combobox is Column(0) ?
 
Am I missing something here?
I *thought* the value in the combobox is Column(0) ?
It is by default. You can change it by setting the BoundColumn-Property of the ComboBox to > 1. (ColumnIndex +1 = BoundColumn)


In the context of this thread, I suspect the term "value", as used by the OP, refers to the entered, visible text, which would correspond to the first visible column.
 
Ser post 5. I think OP wants to limit input to listed items.
 
Am I missing something here?
I *thought* the value in the combobox is Column(0) ?

Yes, by default original data fetches in to combo box and its bound colomn(0), when user inputs data it has to match the value of colomn(0) then run the other code else message to user that doesn't exist in list.
 
What do you think of suggestion in post 5?
 
Yes, by default original data fetches in to combo box and its bound colomn(0), when user inputs data it has to match the value of colomn(0) then run the other code else message to user that doesn't exist in list.
Well as well as using June7's option, I would have thought all you would need to do is test it is not empty.?

I tend to prime my combos with the first item in the list on form load.
Surely if you type something new into the combo, that then becomes the item you are checking against?
 
if you want to limit user input to listed items, set combobox limittolist property to yes. Then validation code is not needed.

Data validation should be done in beforeupdate event.

Why are you duplicating data - why are you saving same data in two tables?


it worked thank you
 
I am curious now, what happens if you delete the entry.?
 

Users who are viewing this thread

Back
Top Bottom