Gents,
I want to save the products table after checking two conditions.
In products table I have fields STOCKCODE (datatype TEXT) (Allows duplicate entries) and BranchName = Data type Text.
Lets say I have already saved a StockCode Ms Office software in BRANCHNAME NEW BRANCH. Now, I want to save another StockCode with same stock code i.e Ms Office software but in another branch called OLD BRANCH in the same Products table.
I am using the following code but its giving error
Code under the MainModule.vb
Public Function IsStockExists(ByVal stockname As String, ByVal BranchName As String) As Boolean
stockname = Replace(stockname, " ", "")
Dim Dbf As New ADODB.Recordset
Dbf.Open("Select * from stockdbf where tempstockcode='" + stockname + "' and BranchName=" & BranchName, Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
--------->> Error (Syntax error (missing operator) in query expression
If Dbf.RecordCount > 0 Then
Dbf.Close()
Return True
Else
Dbf.Close()
Return False
End If
End Function
Code under ProductsForm on AddButton
Private Sub UserButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
If IsStockExists(txtstockcode.Text, cmbBranches.Text) = True Then
MsgBox("The Stock Item Already exists, Please Try Again")
Exit Sub
End If
If MsgBox(" Do u want to save ? ", MsgBoxStyle.YesNo + MsgBoxStyle.Information) = MsgBoxResult.Yes Then
SaveStock()
txtstockcode.Focus()
End If
End Sub
Can anyone help me out on the above issue. Thanks in advance..