checking for a numeric value in a loop
-
With Adodc4.Recordset .MoveFirst Do While Not .EOF Dim strPriceCode As String strPriceCode = DataGrid1.Columns("PriceCode") Dim codeSQL As String codeSQL = "Select PriceCode " & _ " From PriceDescription " & _ " Where PriceCode = '" & strPriceCode & "'" Set RS = Conn.Execute(codeSQL) If RS.BOF And RS.EOF Then MsgBox " '" & strPriceCode & "' Price code does not exist - please try another", vbExclamation, "Invalid data" End If DataGrid1.Columns("Price") = txtTest.Text If Not IsNumeric(Me.txtTest.Text) Then MsgBox "Please enter a valid value for Quantity", vbExclamation, "Missing Quantity" Exit Sub End If Dim cPrice As Currency cPrice = DataGrid1.Columns("Price") 'updating the price table Dim updateSQL As String updateSQL = "Update Price set price = " & cPrice & " " & _ " where PriceCode = '" & strPriceCode & "' " & _ " AND ProductCode = '" & strProductCode & "'" Set RS = Conn.Execute(updateSQL) .MoveNext Loop End With to (attempt to!) explain the above code, i am saving 1 column of a datagrid, and looping through it by means of the Recordset that it is bound to at run time. However, i want to ensure that the value entered at each record is a numberic value, so it has to be included in the loop as can be seen above. However, when i try to run it ( and enter a non-numeric value to test it) i get the following error " Multiple step operation generated errors - check each status value"....is there anything i can do to fix this? if you need any additional information, please let me know! Thanks in advance!
-
With Adodc4.Recordset .MoveFirst Do While Not .EOF Dim strPriceCode As String strPriceCode = DataGrid1.Columns("PriceCode") Dim codeSQL As String codeSQL = "Select PriceCode " & _ " From PriceDescription " & _ " Where PriceCode = '" & strPriceCode & "'" Set RS = Conn.Execute(codeSQL) If RS.BOF And RS.EOF Then MsgBox " '" & strPriceCode & "' Price code does not exist - please try another", vbExclamation, "Invalid data" End If DataGrid1.Columns("Price") = txtTest.Text If Not IsNumeric(Me.txtTest.Text) Then MsgBox "Please enter a valid value for Quantity", vbExclamation, "Missing Quantity" Exit Sub End If Dim cPrice As Currency cPrice = DataGrid1.Columns("Price") 'updating the price table Dim updateSQL As String updateSQL = "Update Price set price = " & cPrice & " " & _ " where PriceCode = '" & strPriceCode & "' " & _ " AND ProductCode = '" & strProductCode & "'" Set RS = Conn.Execute(updateSQL) .MoveNext Loop End With to (attempt to!) explain the above code, i am saving 1 column of a datagrid, and looping through it by means of the Recordset that it is bound to at run time. However, i want to ensure that the value entered at each record is a numberic value, so it has to be included in the loop as can be seen above. However, when i try to run it ( and enter a non-numeric value to test it) i get the following error " Multiple step operation generated errors - check each status value"....is there anything i can do to fix this? if you need any additional information, please let me know! Thanks in advance!
im new to programming... but couldn't you use the IsNumeric() function, if u get true back, just convert it to whichever type u need? CInt, CSng, CDec...etc. Sorry if i don't know what i'm talking about ______________________________________________ "I'm not me when I dream...anymore." -TRUSTcompany