I have this field InvID which is auto increment primary key.
In this lstRecord_DblClick function, i try to use the Left() function to extract the InvID from the program interface which is a lstRecord field. But when the my InvID is 1, or 2 which is one digit, i get the error message: Syntax error(comma) in query expression 'InvID=1,'. I realise i can't use the length as 2, because, this number can grow to more than 2 digit. So i try to use the Split function using the "," delimiter, but i get: Runtime error '13': Type mismatch.
do anyone know whats wrong?
Private Sub lstRecord_DblClick()
Dim selItem As Variant
selItem = selItem + Me.lstRecord.Text
'sInputDat = Left(selItem, 2)
sInputDat = Split(selItem, ",", 0, 1)
moCommand.CommandType = adCmdText
moCommand.ActiveConnection = moConnection
moCommand.CommandText = _
"SELECT ControlNo, CategoryType FROM Inv WHERE InvID = " & sInputDat & ";"
Set rsMain = moCommand.Execute
Me.cboCategoryType = rsMain!CategoryType
Me.txtControlNo = rsMain!ControlNo
End Sub
In this lstRecord_DblClick function, i try to use the Left() function to extract the InvID from the program interface which is a lstRecord field. But when the my InvID is 1, or 2 which is one digit, i get the error message: Syntax error(comma) in query expression 'InvID=1,'. I realise i can't use the length as 2, because, this number can grow to more than 2 digit. So i try to use the Split function using the "," delimiter, but i get: Runtime error '13': Type mismatch.
do anyone know whats wrong?
Private Sub lstRecord_DblClick()
Dim selItem As Variant
selItem = selItem + Me.lstRecord.Text
'sInputDat = Left(selItem, 2)
sInputDat = Split(selItem, ",", 0, 1)
moCommand.CommandType = adCmdText
moCommand.ActiveConnection = moConnection
moCommand.CommandText = _
"SELECT ControlNo, CategoryType FROM Inv WHERE InvID = " & sInputDat & ";"
Set rsMain = moCommand.Execute
Me.cboCategoryType = rsMain!CategoryType
Me.txtControlNo = rsMain!ControlNo
End Sub