Private Sub cboItems_Click()
Dim PosOfSpace1 As Integer
Dim PosOfSpace2 As Integer

' code to put ItemId into txtItemID
PosOfSpace1 = InStr(1, cboItems.Text, " ")
txtItemId = Mid(cboItems.Text, 1, PosOfSpace1 - 1)

'code to put The Item value into txtItemvalue
PosOfSpace2 = InStrRev(1, cboItems.Text, " ")
txtItemValue = Mid(cboItems.Text, 1, PosOfSpace2 - 1)

The first part of the code works(The one that isn't Higlighted), but the other code during run time gives me a Type MisMatch error. I'm tring to reag the Item Value from the right till it gets to the space like the code does for the ItemId. The code for the itemId does work. I'm jsut tring to get the code for Item Value to work So i can do validation testing during a transaction. The Information is loaded into a combo box and looks like this

1 Present 25
1 is the Id and 25 is the value i want to catch and put into a text box

2 Tardy -25
same as above when the spae if rist reached from the right.

Values go up into the thousands like 5000

Hi,

Chage Second part of your code to :

PosOfSpace2 = InStr((PosOfSpace1 + 1), cboItems.Text, " ")
txtItemValue = Mid(cboItems.Text, PosOfSpace2 + 1)

Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.