Self checking a combo box (1 Viewer)

Reshmi mohankumar

Registered User.
Local time
Tomorrow, 00:11
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
 

jdraw

Super Moderator
Staff member
Local time
Today, 14:41
Joined
Jan 23, 2006
Messages
15,378
@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.
 

missinglinq

AWF VIP
Local time
Today, 14:41
Joined
Jun 20, 2003
Messages
6,423
Case Not (Me.cboestdet.Column(0))

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

Linq ;0)>
 

Reshmi mohankumar

Registered User.
Local time
Tomorrow, 00:11
Joined
Dec 5, 2017
Messages
101
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)
 

June7

AWF VIP
Local time
Today, 10:41
Joined
Mar 9, 2014
Messages
5,470
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:

Gasman

Enthusiastic Amateur
Local time
Today, 19:41
Joined
Sep 21, 2011
Messages
14,264
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) ?
 

sonic8

AWF VIP
Local time
Today, 20:41
Joined
Oct 27, 2015
Messages
998
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.
 

June7

AWF VIP
Local time
Today, 10:41
Joined
Mar 9, 2014
Messages
5,470
Ser post 5. I think OP wants to limit input to listed items.
 

Reshmi mohankumar

Registered User.
Local time
Tomorrow, 00:11
Joined
Dec 5, 2017
Messages
101
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.
 

June7

AWF VIP
Local time
Today, 10:41
Joined
Mar 9, 2014
Messages
5,470
What do you think of suggestion in post 5?
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:41
Joined
Sep 21, 2011
Messages
14,264
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?
 

Reshmi mohankumar

Registered User.
Local time
Tomorrow, 00:11
Joined
Dec 5, 2017
Messages
101
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
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:41
Joined
Sep 21, 2011
Messages
14,264
I am curious now, what happens if you delete the entry.?
 

Users who are viewing this thread

Top Bottom